Documentation
¶
Overview ¶
Package safe provides SQL identifier quoting and sanitization utilities to prevent SQL injection in dynamically constructed queries. It implements PostgreSQL-style double-quote quoting by default; dialect-specific quoting is handled at the Dialect layer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidIdent ¶
IsValidIdent checks if a string is a valid unquoted SQL identifier. Valid identifiers contain only ASCII letters, digits, and underscores, and must start with a letter or underscore. An empty string is not valid.
func QuoteIdent ¶
QuoteIdent quotes an identifier (table or column name) safely. It wraps the identifier in double quotes and escapes any embedded double quotes by doubling them. This follows the PostgreSQL quoting convention.
Examples:
QuoteIdent("users") => `"users"`
QuoteIdent(`my"table`) => `"my""table"`
QuoteIdent("") => `""`
Types ¶
This section is empty.