Documentation
¶
Index ¶
- func IsValidIdentifier(s string) bool
- func ParameterizedSQLQueryNamedBasedToIndexBased(dbType base.DXDatabaseType, query string, namedArgs utils.JSON) (string, []any, error)
- func QuoteFieldWithPrefixByDbType(dbType base.DXDatabaseType, field string) string
- func QuoteIdentifierByDbType(dbType base.DXDatabaseType, identifier string) string
- func SQLBuildWhereInClauseInt64(fieldName string, values []int64) string
- func SQLBuildWhereInClauseStrings(fieldName string, values []string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidIdentifier ¶
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 ¶
SQLBuildWhereInClauseInt64 builds a WHERE IN clause for int64 values
func SQLBuildWhereInClauseStrings ¶
SQLBuildWhereInClauseStrings builds a WHERE IN clause for string values
Types ¶
This section is empty.