utils

package
v1.127.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 6 Imported by: 0

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