Skip to main content

Module sql

Module sql 

Source
Expand description

SQLite DDL generation from the schema model. Kept dialect-shaped (every statement goes through this module) so a second backend is a new module, not a rewrite.

Functions§

column_sql
One column definition line. auto_pk says whether this table uses the conventional id: i64 surrogate key (rendered inline as INTEGER PRIMARY KEY AUTOINCREMENT); composite keys are rendered as a table constraint by create_table_sql instead.
composite_index_name
composite_index_sqls
CREATE [UNIQUE] INDEX statements for every struct-level #[orm(unique(...))] / #[orm(index(...))] — composite constraints, enforced as indexes (not inline table constraints) so they can be added/dropped without a rebuild.
create_table_sql
index_name
index_sqls
CREATE INDEX statements for every #[orm(index)] column.
quote_ident
A table/column/index name, double-quoted for SQL. Every identifier the ORM emits goes through this, so names that collide with SQL keywords (order, group, index, …) just work.