utils

package
v1.135.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidIdentifier

func IsValidIdentifier(s string) bool

IsValidIdentifier checks if a string is a valid SQL identifier (alphanumeric + underscore, optionally with dot for table.field)

func ParameterizedSQLQueryNamedBasedToIndexBased

func ParameterizedSQLQueryNamedBasedToIndexBased(dbType base.DXDatabaseType, query string, namedArgs utils.JSON) (string, []any, error)

ParameterizedSQLQueryNamedBasedToIndexBased converts a SQL query with named parameters (:param_name) to index-based positional parameters ($1, $2 for PostgreSQL, ? for MariaDB, etc.) and returns the converted query string along with an ordered slice of argument values.

Example:

query: "SELECT * FROM users WHERE name = :name AND age > :age"
namedArgs: {"name": "John", "age": 25}

For PostgreSQL returns:
  query: "SELECT * FROM users WHERE name = $1 AND age > $2"
  args: ["John", 25]

For MariaDB returns:
  query: "SELECT * FROM users WHERE name = ? AND age > ?"
  args: ["John", 25]

func QuoteFieldWithPrefixByDbType

func QuoteFieldWithPrefixByDbType(dbType base.DXDatabaseType, field string) string

QuoteFieldWithPrefixByDbType quotes a field that may have table prefix (e.g., "t.field_name" -> "t"."field_name")

func QuoteIdentifierByDbType

func QuoteIdentifierByDbType(dbType base.DXDatabaseType, identifier string) string

QuoteIdentifierByDbType quotes a SQL identifier based on database type to prevent SQL injection

func SQLBuildWhereInClauseInt64

func SQLBuildWhereInClauseInt64(fieldName string, values []int64) string

SQLBuildWhereInClauseInt64 builds a WHERE IN clause for int64 values

func SQLBuildWhereInClauseStrings

func SQLBuildWhereInClauseStrings(fieldName string, values []string) string

SQLBuildWhereInClauseStrings builds a WHERE IN clause for string values

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL