Skip to main content

Crate ruprizzle_dialect

Crate ruprizzle_dialect 

Source
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 DbDialect trait 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.
  • Stmt carries destructive and transactional metadata so the migration planner does not have to rediscover per-dialect quirks.
  • Helper functions such as full_create_table and full_alter_column take a full Schema because generating correct foreign keys and table rebuilds needs resolved relation information that a single Model does not carry.

§Adding a dialect

  1. Add a variant to Provider in core.
  2. Implement DbDialect for a new type.
  3. Add it to dialect_for.
  4. Add a row to the conformance suite so the new backend cannot rot.

Structs§

Capabilities
What a dialect can and cannot do.
MySqlDialect
The MySQL / MariaDB dialect implementation.
PostgresDialect
The PostgreSQL dialect implementation.
SqliteDialect
The SQLite dialect implementation.
Stmt
A single DDL statement plus metadata the migration planner needs.

Enums§

DialectError
An error produced while turning an IR field into a SQL column.
JsonSupport
How a dialect stores JSON.
RustType
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_column with 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.