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 render helpers for identifier writing and placeholder formatting. -
render_estimate.rs— Conservative SQL/params capacity estimation used by the dialect renderers to preallocateStringandVec<Value>buffers. -
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 contains / contained-by via JSON_CONTAINS(target, candidate).
The generic MysqlDialect intentionally rejects overlap rendering because the
workspace-wide "mysql" provider also covers MySQL-family backends where
JSON_OVERLAPS is not guaranteed. SQLite uses json_each + correlated
EXISTS predicates so JSON null elements are preserved instead of being
lost to IN / NOT IN null semantics. Arrays are bound as JSON strings by
the connector layer, so no special client-side handling is needed.