Expand description
SQL dialect abstraction.
This crate is the seam between the dialect-agnostic Schema produced by the
parser and the SQL that a specific database understands. It is used by both
the migration engine (which needs DDL) and the codegen crate (which needs Rust
types and dialect-specific warnings).
§Design
- The
DbDialecttrait is object-safe and the single interface the rest of the workspace talks to. - Every DDL operation returns a
Vec<Stmt>because one logical change can require several physical statements, especially on SQLite. Stmtcarriesdestructiveandtransactionalmetadata so the migration planner does not have to rediscover per-dialect quirks.- Helper functions such as
full_create_tableandfull_alter_columntake a fullSchemabecause generating correct foreign keys and table rebuilds needs resolved relation information that a singleModeldoes not carry.
§Adding a dialect
- Add a variant to
Providerincore. - Implement
DbDialectfor a new type. - Add it to
dialect_for. - Add a row to the conformance suite so the new backend cannot rot.
Structs§
- Capabilities
- What a dialect can and cannot do.
- MySql
Dialect - The MySQL / MariaDB dialect implementation.
- Postgres
Dialect - The PostgreSQL dialect implementation.
- Sqlite
Dialect - The SQLite dialect implementation.
- Stmt
- A single DDL statement plus metadata the migration planner needs.
Enums§
- Dialect
Error - An error produced while turning an IR field into a SQL column.
- Json
Support - How a dialect stores JSON.
- Rust
Type - The Rust type a column maps to, as seen by codegen.
Traits§
- DbDialect
- The SQL dialect abstraction.
Functions§
- check_
schema_ capabilities - Checks a schema for constructs that the active provider handles poorly.
- dialect_
for - Returns the dialect implementation for a provider.
- full_
alter_ column - Creates the full sequence of statements needed to change a column on SQLite, including the table rebuild, index recreation, and foreign-key recreation.
- full_
alter_ column_ with_ source full_alter_columnwith an explicit source model.- full_
create_ table - Creates the full set of statements needed to create a model, including foreign keys, for the initial schema creation.