Module helpers

Module helpers 

Source

Functions§

apply_column_type_with_table
Apply vespertide ColumnType to sea_query ColumnDef with table-aware enum type naming
build_check_constraint_name
Generate CHECK constraint name for SQLite enum column. Uses double underscore to separate table name from the rest. Format: chk_{table}__{column}
build_create_enum_type_sql
Generate CREATE TYPE SQL for an enum type (PostgreSQL only) Returns None for non-PostgreSQL backends or non-enum types
build_drop_enum_type_sql
Generate DROP TYPE SQL for an enum type (PostgreSQL only) Returns None for non-PostgreSQL backends or non-enum types
build_enum_type_name
Generate enum type name with table prefix to avoid conflicts. Always includes table name to ensure uniqueness across tables. Format: {table}_{enum_name}
build_foreign_key_name
Generate foreign key constraint name from table name, columns, and optional user-provided key. Always includes table name to avoid conflicts across tables. Uses double underscore to separate table name from the rest. Format: fk_{table}{key} or fk_{table}{col1}_{col2}…
build_index_name
Generate index name from table name, columns, and optional user-provided key. Always includes table name to avoid conflicts across tables. Uses double underscore to separate table name from the rest. Format: ix_{table}{key} or ix_{table}{col1}_{col2}…
build_query_statement
Helper function to convert a query statement (INSERT, SELECT, etc.) to SQL for a specific backend
build_schema_statement
Helper function to convert a schema statement to SQL for a specific backend
build_sea_column_def_with_table
Build sea_query ColumnDef from vespertide ColumnDef for a specific backend with table-aware enum naming
build_sqlite_enum_check_clause
Generate CHECK constraint expression for SQLite enum column Returns the constraint clause like: CONSTRAINT “chk_table_col” CHECK (col IN (‘val1’, ‘val2’))
build_sqlite_enum_check_name
Alias for build_check_constraint_name for SQLite enum columns
build_unique_constraint_name
Generate unique constraint name from table name, columns, and optional user-provided key. Always includes table name to avoid conflicts across tables. Uses double underscore to separate table name from the rest. Format: uq_{table}{key} or uq_{table}{col1}_{col2}…
collect_sqlite_enum_check_clauses
Collect all CHECK constraints for enum columns in a table (for SQLite)
convert_default_for_backend
Convert a default value string to the appropriate backend-specific expression
get_enum_name
Extract enum name from column type if it’s an enum
normalize_enum_default
Normalize a default value for enum columns - add quotes if needed This is used for SQL expressions (INSERT, UPDATE) where enum values need quoting
normalize_fill_with
Normalize fill_with value - empty string becomes ‘’ (SQL empty string literal)
reference_action_sql
Convert vespertide ReferenceAction to SQL string
to_sea_fk_action
Convert vespertide ReferenceAction to sea_query ForeignKeyAction