GenericSqlWriter

Struct GenericSqlWriter 

Source
pub struct GenericSqlWriter;
Expand description

Fallback generic SQL writer (closest to PostgreSQL / DuckDB conventions).

Implementations§

Source§

impl GenericSqlWriter

Source

pub fn new() -> Self

Construct a new generic writer.

Trait Implementations§

Source§

impl SqlWriter for GenericSqlWriter

Source§

fn as_dyn(&self) -> &dyn SqlWriter

Source§

fn alias_declaration(&self, context: &mut Context) -> bool

Whether the current fragment context allows alias declaration.
Source§

fn update_metadata<'s>( &'s self, out: &mut DynQuery, metadata: Cow<'s, QueryMetadata>, )

Source§

fn write_escaped( &self, _context: &mut Context, out: &mut DynQuery, value: &str, search: char, replace: &str, )

Escape occurrences of search char with replace while copying into buffer.
Source§

fn write_identifier_quoted( &self, context: &mut Context, out: &mut DynQuery, value: &str, )

Quote identifiers (“name”) doubling inner quotes.
Source§

fn write_table_ref( &self, context: &mut Context, out: &mut DynQuery, value: &TableRef, )

Render a table reference with optional alias.
Source§

fn write_column_ref( &self, context: &mut Context, out: &mut DynQuery, value: &ColumnRef, )

Render a column reference optionally qualifying with schema/table.
Source§

fn write_column_overridden_type( &self, _context: &mut Context, out: &mut DynQuery, _column: &ColumnDef, types: &BTreeMap<&'static str, &'static str>, )

Render the SQL overridden type.
Source§

fn write_column_type( &self, context: &mut Context, out: &mut DynQuery, value: &Value, )

Render the SQL type for a Value prototype.
Source§

fn write_value(&self, context: &mut Context, out: &mut DynQuery, value: &Value)

Render a concrete value (including proper quoting / escaping).
Source§

fn write_value_none(&self, context: &mut Context, out: &mut DynQuery)

Render NULL literal.
Source§

fn write_value_bool( &self, context: &mut Context, out: &mut DynQuery, value: bool, )

Render boolean literal.
Source§

fn write_value_infinity( &self, context: &mut Context, out: &mut DynQuery, negative: bool, )

Render +/- INF via CAST for dialect portability.
Source§

fn write_value_nan(&self, context: &mut Context, out: &mut DynQuery)

Render NaN via CAST for dialect portability.
Source§

fn write_value_string( &self, context: &mut Context, out: &mut DynQuery, value: &str, )

Render and escape a string literal using single quotes.
Source§

fn write_value_blob( &self, context: &mut Context, out: &mut DynQuery, value: &[u8], )

Render a blob literal using hex escapes.
Source§

fn write_value_date( &self, context: &mut Context, out: &mut DynQuery, value: &Date, timestamp: bool, )

Render a DATE literal (optionally as part of TIMESTAMP composition).
Source§

fn write_value_time( &self, context: &mut Context, out: &mut DynQuery, value: &Time, timestamp: bool, )

Render a TIME literal (optionally as part of TIMESTAMP composition).
Source§

fn write_value_timestamp( &self, context: &mut Context, out: &mut DynQuery, value: &PrimitiveDateTime, )

Render a TIMESTAMP literal.
Source§

fn write_value_timestamptz( &self, context: &mut Context, out: &mut DynQuery, value: &OffsetDateTime, )

Render a TIMESTAMPTZ literal.
Source§

fn value_interval_units(&self) -> &[(&str, i128)]

Ordered units used to decompose intervals.
Source§

fn write_value_interval( &self, context: &mut Context, out: &mut DynQuery, value: &Interval, )

Render INTERVAL literal using largest representative units.
Source§

fn write_value_uuid( &self, context: &mut Context, out: &mut DynQuery, value: &Uuid, )

Render UUID literal.
Source§

fn write_value_list( &self, context: &mut Context, out: &mut DynQuery, value: Either<&Box<[Value]>, &Vec<Value>>, _ty: &Value, _elem_ty: &Value, )

Render list/array literal.
Source§

fn write_value_map( &self, context: &mut Context, out: &mut DynQuery, value: &HashMap<Value, Value>, )

Render map literal.
Source§

fn write_value_struct( &self, context: &mut Context, out: &mut DynQuery, value: &Vec<(String, Value)>, )

Render struct literal.
Source§

fn expression_unary_op_precedence(&self, value: &UnaryOpType) -> i32

Precedence table for unary operators.
Source§

fn expression_binary_op_precedence(&self, value: &BinaryOpType) -> i32

Precedence table for binary operators.
Source§

fn write_expression_operand( &self, context: &mut Context, out: &mut DynQuery, value: &Operand<'_>, )

Render an operand (literal / variable / nested expression).
Source§

fn write_expression_operand_question_mark( &self, _context: &mut Context, out: &mut DynQuery, )

Render parameter placeholder (dialect may override).
Source§

fn write_expression_unary_op( &self, context: &mut Context, out: &mut DynQuery, value: &UnaryOp<&dyn Expression>, )

Render unary operator expression.
Source§

fn write_expression_binary_op( &self, context: &mut Context, out: &mut DynQuery, value: &BinaryOp<&dyn Expression, &dyn Expression>, )

Render binary operator expression handling precedence / parenthesis.
Source§

fn write_expression_cast( &self, context: &mut Context, out: &mut DynQuery, expr: &dyn Expression, ty: &dyn Expression, )

Render casting expression
Source§

fn write_expression_ordered( &self, context: &mut Context, out: &mut DynQuery, value: &Ordered<&dyn Expression>, )

Render ordered expression inside ORDER BY.
Source§

fn write_join_type( &self, _context: &mut Context, out: &mut DynQuery, join_type: &JoinType, )

Render join keyword(s) for the given join type.
Source§

fn write_join( &self, context: &mut Context, out: &mut DynQuery, join: &Join<&dyn DataSet, &dyn DataSet, &dyn Expression>, )

Render a JOIN clause.
Source§

fn write_transaction_begin(&self, out: &mut DynQuery)

Emit BEGIN statement.
Source§

fn write_transaction_commit(&self, out: &mut DynQuery)

Emit COMMIT statement.
Source§

fn write_transaction_rollback(&self, out: &mut DynQuery)

Emit ROLLBACK statement.
Source§

fn write_create_schema<E>(&self, out: &mut DynQuery, if_not_exists: bool)
where Self: Sized, E: Entity,

Emit CREATE SCHEMA.
Source§

fn write_drop_schema<E>(&self, out: &mut DynQuery, if_exists: bool)
where Self: Sized, E: Entity,

Emit DROP SCHEMA.
Source§

fn write_create_table<E>(&self, out: &mut DynQuery, if_not_exists: bool)
where Self: Sized, E: Entity,

Emit CREATE TABLE with columns, constraints & comments.
Source§

fn write_create_table_column_fragment( &self, context: &mut Context, out: &mut DynQuery, column: &ColumnDef, )
where Self: Sized,

Emit single column definition fragment.
Source§

fn write_create_table_primary_key_fragment<'a, It>( &self, context: &mut Context, out: &mut DynQuery, primary_key: It, )
where Self: Sized, It: IntoIterator<Item = &'a ColumnDef>, It::IntoIter: Clone,

Emit PRIMARY KEY constraint for the CREATE TABLE query
Source§

fn write_create_table_references_action( &self, _context: &mut Context, out: &mut DynQuery, action: &Action, )

Emit referential action keyword.
Source§

fn write_column_comment_inline( &self, _context: &mut Context, _out: &mut DynQuery, _column: &ColumnDef, )
where Self: Sized,

Source§

fn write_column_comments_statements<E>( &self, context: &mut Context, out: &mut DynQuery, )
where Self: Sized, E: Entity,

Emit COMMENT ON COLUMN statements for columns carrying comments.
Source§

fn write_drop_table<E>(&self, out: &mut DynQuery, if_exists: bool)
where Self: Sized, E: Entity,

Emit DROP TABLE statement.
Source§

fn write_select<'a, Data>( &self, out: &mut DynQuery, query: &impl SelectQuery<Data>, )
where Self: Sized, Data: DataSet + 'a,

Emit SELECT statement (projection, FROM, WHERE, ORDER, LIMIT).
Source§

fn write_insert<'b, E>( &self, out: &mut DynQuery, entities: impl IntoIterator<Item = &'b E>, update: bool, )
where Self: Sized, E: Entity + 'b,

Emit INSERT INTO (single/multi-row) optionally with ON CONFLICT DO UPDATE.
Source§

fn write_insert_update_fragment<'a, E>( &self, context: &mut Context, out: &mut DynQuery, columns: impl Iterator<Item = &'a ColumnDef> + Clone, )
where Self: Sized, E: Entity,

Emit ON CONFLICT DO UPDATE fragment for upsert.
Source§

fn write_delete<E>(&self, out: &mut DynQuery, condition: impl Expression)
where Self: Sized, E: Entity,

Emit DELETE statement with WHERE clause.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.