pub struct Serializer<'a> { /* private fields */ }Expand description
Serialize a statement to a SQL string
Implementations§
Source§impl<'a> Serializer<'a>
impl<'a> Serializer<'a>
Sourcepub fn postgresql(schema: &'a Schema) -> Self
pub fn postgresql(schema: &'a Schema) -> Self
Creates a serializer that emits PostgreSQL SQL.
Source§impl<'a> Serializer<'a>
impl<'a> Serializer<'a>
Sourcepub fn serialize(&self, stmt: &Statement) -> String
pub fn serialize(&self, stmt: &Statement) -> String
Serializes a Statement to a SQL string with all values inlined as
literals (no bind parameters). Appends a trailing semicolon.
Use this for DDL statements (CREATE TABLE, CREATE TYPE, etc.) where
bind parameters are not supported. DML statements should already have
their parameters extracted (as Expr::Arg placeholders) before reaching
the serializer.
Sourcepub fn serialize_with_arg_order(&self, stmt: &Statement) -> (String, Vec<usize>)
pub fn serialize_with_arg_order(&self, stmt: &Statement) -> (String, Vec<usize>)
Serializes a Statement and returns both the SQL string and the order
in which Expr::Arg(n) placeholders appear in the SQL.
The arg order is needed by MySQL which uses positional ? without
indices — the caller must reorder its params vec to match the occurrence
order. PostgreSQL and SQLite use indexed placeholders ($1, ?1) so
they can ignore the arg order.
Sourcepub fn serialize_transaction(&self, op: &Transaction) -> String
pub fn serialize_transaction(&self, op: &Transaction) -> String
Serialize a transaction control operation to a SQL string.
The generated SQL is flavor-specific (e.g., MySQL uses START TRANSACTION
while other databases use BEGIN). Savepoints are named sp_{id}.