nautilus-dialect
SQL dialect renderers for the Nautilus ORM.
This crate translates query ASTs produced by nautilus-core into dialect-specific
SQL strings with bound parameters ready for execution via nautilus-connector.
Supported dialects
| Dialect | Struct | Placeholders | Quoting | RETURNING |
|---|---|---|---|---|
| PostgreSQL | PostgresDialect |
$1, $2, ... |
"name" |
yes |
| MySQL | MysqlDialect |
? |
`name` |
no (emulated) |
| SQLite | SqliteDialect |
? |
"name" |
yes (3.35+) |
Usage
use ;
use ;
let select = from_table
.filter
.build?;
let sql = PostgresDialect.render_select?;
// sql.text => SELECT * FROM "users" WHERE ("email" = $1)
// sql.params => [Value::String("alice@example.com")]
Architecture
The crate is organized as follows:
-
lib.rs— Public API:Dialecttrait,Sqlstruct, shared rendering macros (render_insert_body!,render_update_body!,render_delete_body!,render_select_body_core!,render_returning!), and shared identifier-quoting helpers (double_quote_identifier,backtick_quote_identifier). -
postgres.rs— PostgreSQL renderer. Handles$Nplaceholders,DISTINCT ON,FILTER (WHERE ...)on aggregates, and@>/<@/&&array operators. -
mysql.rs— MySQL renderer. Uses?placeholders and backtick quoting. EmitsLIMIT 18446744073709551615when onlyOFFSETis requested (MySQL requiresLIMITbeforeOFFSET).RETURNINGis silently omitted. -
sqlite.rs— SQLite renderer. Uses?placeholders and ANSI double-quote quoting. SupportsRETURNING(SQLite 3.35+) and nativeFILTER (WHERE ...)on aggregates.
Array operators
PostgreSQL natively supports @> (contains), <@ (contained by), and &&
(overlaps) array operators via BinaryOp::ArrayContains,
BinaryOp::ArrayContainedBy, and BinaryOp::ArrayOverlaps.
MySQL emulates these via JSON_CONTAINS(target, candidate) for contains /
contained-by (swapping argument order) and JSON_OVERLAPS(a, b) for overlap
(requires MySQL 8.0.17+). SQLite uses json_each subqueries to check element
membership. Arrays are bound as JSON strings by the connector layer, so no
special client-side handling is needed.