Documentation
¶
Overview ¶
Package utils provides shared helper functions for SQL generation and value formatting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertDefaultValue ¶
ConvertDefaultValue converts a YAML default value to database-specific SQL This is a common utility function that all providers can use
func FormatDefaultValue ¶
FormatDefaultValue formats a default value for use in SQL DDL. SQL expressions, numeric values, and boolean/null literals are returned verbatim. All other values are wrapped in single quotes as string literals.
func HandleFallbackDefault ¶
HandleFallbackDefault handles cases where no schema mapping exists. It normalises NULL to uppercase and delegates to FormatDefaultValue for expression detection and proper formatting.
func IsSQLExpression ¶
IsSQLExpression returns true when the value is already a valid SQL expression that should be emitted verbatim rather than wrapped in single quotes. This covers:
- Single-quoted string literals already in SQL form: 'value', '[]'::jsonb
- SQL function calls: gen_random_uuid(), uuid_generate_v4()
- Type cast expressions: '{}'::jsonb
- SQL keywords (all-uppercase, letters and underscores): CURRENT_TIMESTAMP
- NULL/null, TRUE/true, FALSE/false literals
func SafeConstraintName ¶
SafeConstraintName returns a PostgreSQL-safe constraint name (max 63 chars). If the full name exceeds 63 characters, it is truncated to 54 chars and an 8-hex-char FNV-32a hash of the original name is appended (54+1+8=63).
Types ¶
This section is empty.