Skip to main content

Module dialect

Module dialect 

Source
Expand description

Abstraction over SQL dialect differences.

Different databases vary in placeholder syntax ($N, ?, ?N, @PN), result-returning clauses (RETURNING, OUTPUT INSERTED), identifier quoting, upsert syntax, and transaction control keywords. Operations in prax-query compose SQL through a &dyn SqlDialect, obtained from their bound QueryEngine via engine.dialect(), so a single build_sql emission path serves every backend.

Structs§

Cql
Cassandra Query Language dialect, used by ScyllaEngine and the Cassandra driver. CQL overlaps with SQL for the basic SELECT/INSERT/UPDATE/DELETE ... WHERE shapes the Client API emits, but diverges on many details: no RETURNING, no cross-partition joins, no traditional ON CONFLICT (use IF NOT EXISTS LWT instead), no transactions, and ? positional placeholders only. The CQL dialect emits that subset safely; engine-level compensation covers the RETURNING gap the way MySQL does.
Mssql
Microsoft SQL Server dialect: @PN placeholders, OUTPUT INSERTED.*, bracket-quoted identifiers, BEGIN/COMMIT/ROLLBACK TRANSACTION. Upserts require MERGE, which the engine post-processes; the upsert clause emits empty.
Mysql
MySQL dialect: ? placeholders (positionless), no RETURNING support (that’s a MariaDB 10.5+ extension, not MySQL 8.0), backtick-quoted identifiers, ON DUPLICATE KEY UPDATE ... upserts.
NotSql
Inert dialect for engines that do not emit SQL (document stores such as MongoDB). Every helper returns an empty or identity value. Calling these methods is a bug — no SQL string built from this dialect would be valid against any real database. The driver’s own non-SQL operation path should never reach these helpers.
Postgres
PostgreSQL dialect: $N placeholders, RETURNING, "ident" quoting, ON CONFLICT (cols) DO UPDATE SET ... upserts, DISTINCT ON support.
Sqlite
SQLite dialect: ?N placeholders, RETURNING, "ident" quoting, ON CONFLICT (cols) DO UPDATE SET ... upserts.

Traits§

SqlDialect
Cross-dialect SQL emission helpers.