pub trait SqlWriter: Send {
Show 65 methods
// Required method
fn as_dyn(&self) -> &dyn SqlWriter;
// Provided methods
fn separator(&self) -> &str { ... }
fn is_alias_declaration(&self, context: &mut Context) -> bool { ... }
fn write_identifier(
&self,
_context: &mut Context,
out: &mut DynQuery,
value: &str,
quoted: bool,
) { ... }
fn write_table_ref(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &TableRef,
) { ... }
fn write_column_ref(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &ColumnRef,
) { ... }
fn write_column_overridden_type(
&self,
_context: &mut Context,
out: &mut DynQuery,
_column: &ColumnDef,
types: &BTreeMap<&'static str, &'static str>,
) { ... }
fn write_column_type(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Value,
) { ... }
fn write_value(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Value,
) { ... }
fn write_null(&self, context: &mut Context, out: &mut DynQuery) { ... }
fn write_bool(&self, context: &mut Context, out: &mut DynQuery, value: bool) { ... }
fn write_value_i8(
&self,
context: &mut Context,
out: &mut DynQuery,
value: i8,
) { ... }
fn write_value_i16(
&self,
context: &mut Context,
out: &mut DynQuery,
value: i16,
) { ... }
fn write_value_i32(
&self,
context: &mut Context,
out: &mut DynQuery,
value: i32,
) { ... }
fn write_value_i64(
&self,
context: &mut Context,
out: &mut DynQuery,
value: i64,
) { ... }
fn write_value_i128(
&self,
context: &mut Context,
out: &mut DynQuery,
value: i128,
) { ... }
fn write_value_u8(
&self,
context: &mut Context,
out: &mut DynQuery,
value: u8,
) { ... }
fn write_value_u16(
&self,
context: &mut Context,
out: &mut DynQuery,
value: u16,
) { ... }
fn write_value_u32(
&self,
context: &mut Context,
out: &mut DynQuery,
value: u32,
) { ... }
fn write_value_u64(
&self,
context: &mut Context,
out: &mut DynQuery,
value: u64,
) { ... }
fn write_value_u128(
&self,
context: &mut Context,
out: &mut DynQuery,
value: u128,
) { ... }
fn write_value_f32(
&self,
context: &mut Context,
out: &mut DynQuery,
value: f32,
) { ... }
fn write_value_f64(
&self,
context: &mut Context,
out: &mut DynQuery,
value: f64,
) { ... }
fn write_string(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &str,
) { ... }
fn write_blob(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &[u8],
) { ... }
fn write_date(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Date,
) { ... }
fn write_time(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Time,
) { ... }
fn write_timestamp(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &PrimitiveDateTime,
) { ... }
fn write_timestamptz(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &OffsetDateTime,
) { ... }
fn value_interval_units(&self) -> &[(&str, i128)] { ... }
fn write_interval(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Interval,
) { ... }
fn write_uuid(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Uuid,
) { ... }
fn write_list(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &mut dyn Iterator<Item = &dyn Expression>,
_ty: Option<&Value>,
_is_array: bool,
) { ... }
fn write_tuple(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &mut dyn Iterator<Item = &dyn Expression>,
) { ... }
fn write_map(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &HashMap<Value, Value>,
) { ... }
fn write_json(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Value,
) { ... }
fn write_struct(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Vec<(String, Value)>,
) { ... }
fn write_function(
&self,
context: &mut Context,
out: &mut DynQuery,
function: &str,
args: &[&dyn Expression],
) { ... }
fn expression_unary_op_precedence(&self, value: &UnaryOpType) -> i32 { ... }
fn expression_binary_op_precedence(&self, value: &BinaryOpType) -> i32 { ... }
fn write_operand(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Operand<'_>,
) { ... }
fn write_question_mark(&self, context: &mut Context, out: &mut DynQuery) { ... }
fn write_current_timestamp_ms(
&self,
_context: &mut Context,
out: &mut DynQuery,
) { ... }
fn write_unary_op(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &UnaryOp<&dyn Expression>,
) { ... }
fn write_binary_op(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &BinaryOp<&dyn Expression, &dyn Expression>,
) { ... }
fn write_cast(
&self,
context: &mut Context,
out: &mut DynQuery,
expr: &dyn Expression,
ty: &dyn Expression,
) { ... }
fn write_ordered(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Ordered<&dyn Expression>,
) { ... }
fn write_join_type(
&self,
_context: &mut Context,
out: &mut DynQuery,
join_type: &JoinType,
) { ... }
fn write_join(
&self,
context: &mut Context,
out: &mut DynQuery,
join: &Join<&dyn Dataset, &dyn Dataset, &dyn Expression>,
) { ... }
fn write_transaction_begin(&self, out: &mut DynQuery) { ... }
fn write_transaction_commit(&self, out: &mut DynQuery) { ... }
fn write_transaction_rollback(&self, out: &mut DynQuery) { ... }
fn write_create_schema<E>(&self, out: &mut DynQuery, if_not_exists: bool)
where Self: Sized,
E: Entity { ... }
fn write_drop_schema<E>(&self, out: &mut DynQuery, if_exists: bool)
where Self: Sized,
E: Entity { ... }
fn write_create_table<E>(&self, out: &mut DynQuery, if_not_exists: bool)
where Self: Sized,
E: Entity { ... }
fn write_create_table_column_fragment(
&self,
context: &mut Context,
out: &mut DynQuery,
column: &ColumnDef,
)
where Self: Sized { ... }
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 { ... }
fn write_create_table_references_action(
&self,
_context: &mut Context,
out: &mut DynQuery,
action: &Action,
) { ... }
fn write_column_comment_inline(
&self,
_context: &mut Context,
_out: &mut DynQuery,
_column: &ColumnDef,
)
where Self: Sized { ... }
fn write_column_comments_statements<E>(
&self,
context: &mut Context,
out: &mut DynQuery,
)
where Self: Sized,
E: Entity { ... }
fn write_drop_table<E>(&self, out: &mut DynQuery, if_exists: bool)
where Self: Sized,
E: Entity { ... }
fn write_select<'a, Data>(
&self,
out: &mut DynQuery,
query: &impl SelectQuery<Data>,
)
where Self: Sized,
Data: Dataset + 'a { ... }
fn write_insert<'b, E>(
&self,
out: &mut DynQuery,
entities: impl IntoIterator<Item = &'b E>,
update: bool,
)
where Self: Sized,
E: Entity + 'b { ... }
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 { ... }
fn write_delete<E>(&self, out: &mut DynQuery, condition: impl Expression)
where Self: Sized,
E: Entity { ... }
}Expand description
SQL dialect printer.
Required Methods§
Provided Methods§
Sourcefn is_alias_declaration(&self, context: &mut Context) -> bool
fn is_alias_declaration(&self, context: &mut Context) -> bool
Determines if the current SQL context supports alias declarations.
Sourcefn write_identifier(
&self,
_context: &mut Context,
out: &mut DynQuery,
value: &str,
quoted: bool,
)
fn write_identifier( &self, _context: &mut Context, out: &mut DynQuery, value: &str, quoted: bool, )
Writes an identifier (like a table or column name) to the query builder, optionally quoting it.
Sourcefn write_table_ref(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &TableRef,
)
fn write_table_ref( &self, context: &mut Context, out: &mut DynQuery, value: &TableRef, )
Write table reference.
Sourcefn write_column_ref(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &ColumnRef,
)
fn write_column_ref( &self, context: &mut Context, out: &mut DynQuery, value: &ColumnRef, )
Write column reference.
Sourcefn write_column_overridden_type(
&self,
_context: &mut Context,
out: &mut DynQuery,
_column: &ColumnDef,
types: &BTreeMap<&'static str, &'static str>,
)
fn write_column_overridden_type( &self, _context: &mut Context, out: &mut DynQuery, _column: &ColumnDef, types: &BTreeMap<&'static str, &'static str>, )
Write overridden type.
Sourcefn write_column_type(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Value,
)
fn write_column_type( &self, context: &mut Context, out: &mut DynQuery, value: &Value, )
Write SQL type name.
Sourcefn write_value(&self, context: &mut Context, out: &mut DynQuery, value: &Value)
fn write_value(&self, context: &mut Context, out: &mut DynQuery, value: &Value)
Write value.
fn write_null(&self, context: &mut Context, out: &mut DynQuery)
fn write_bool(&self, context: &mut Context, out: &mut DynQuery, value: bool)
fn write_value_i8(&self, context: &mut Context, out: &mut DynQuery, value: i8)
fn write_value_i16(&self, context: &mut Context, out: &mut DynQuery, value: i16)
fn write_value_i32(&self, context: &mut Context, out: &mut DynQuery, value: i32)
fn write_value_i64(&self, context: &mut Context, out: &mut DynQuery, value: i64)
fn write_value_i128( &self, context: &mut Context, out: &mut DynQuery, value: i128, )
fn write_value_u8(&self, context: &mut Context, out: &mut DynQuery, value: u8)
fn write_value_u16(&self, context: &mut Context, out: &mut DynQuery, value: u16)
fn write_value_u32(&self, context: &mut Context, out: &mut DynQuery, value: u32)
fn write_value_u64(&self, context: &mut Context, out: &mut DynQuery, value: u64)
fn write_value_u128( &self, context: &mut Context, out: &mut DynQuery, value: u128, )
fn write_value_f32(&self, context: &mut Context, out: &mut DynQuery, value: f32)
fn write_value_f64(&self, context: &mut Context, out: &mut DynQuery, value: f64)
fn write_string(&self, context: &mut Context, out: &mut DynQuery, value: &str)
fn write_blob(&self, context: &mut Context, out: &mut DynQuery, value: &[u8])
fn write_date(&self, context: &mut Context, out: &mut DynQuery, value: &Date)
fn write_time(&self, context: &mut Context, out: &mut DynQuery, value: &Time)
fn write_timestamp( &self, context: &mut Context, out: &mut DynQuery, value: &PrimitiveDateTime, )
fn write_timestamptz( &self, context: &mut Context, out: &mut DynQuery, value: &OffsetDateTime, )
Sourcefn value_interval_units(&self) -> &[(&str, i128)]
fn value_interval_units(&self) -> &[(&str, i128)]
Units used to decompose intervals (notice the decreasing order).
fn write_interval( &self, context: &mut Context, out: &mut DynQuery, value: &Interval, )
fn write_uuid(&self, context: &mut Context, out: &mut DynQuery, value: &Uuid)
fn write_list( &self, context: &mut Context, out: &mut DynQuery, value: &mut dyn Iterator<Item = &dyn Expression>, _ty: Option<&Value>, _is_array: bool, )
fn write_tuple( &self, context: &mut Context, out: &mut DynQuery, value: &mut dyn Iterator<Item = &dyn Expression>, )
fn write_map( &self, context: &mut Context, out: &mut DynQuery, value: &HashMap<Value, Value>, )
fn write_json(&self, context: &mut Context, out: &mut DynQuery, value: &Value)
fn write_struct( &self, context: &mut Context, out: &mut DynQuery, value: &Vec<(String, Value)>, )
fn write_function( &self, context: &mut Context, out: &mut DynQuery, function: &str, args: &[&dyn Expression], )
Sourcefn expression_unary_op_precedence(&self, value: &UnaryOpType) -> i32
fn expression_unary_op_precedence(&self, value: &UnaryOpType) -> i32
Precedence table for unary operators.
Sourcefn expression_binary_op_precedence(&self, value: &BinaryOpType) -> i32
fn expression_binary_op_precedence(&self, value: &BinaryOpType) -> i32
Precedence table for binary operators.
fn write_operand( &self, context: &mut Context, out: &mut DynQuery, value: &Operand<'_>, )
fn write_question_mark(&self, context: &mut Context, out: &mut DynQuery)
fn write_current_timestamp_ms(&self, _context: &mut Context, out: &mut DynQuery)
fn write_unary_op( &self, context: &mut Context, out: &mut DynQuery, value: &UnaryOp<&dyn Expression>, )
Sourcefn write_binary_op(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &BinaryOp<&dyn Expression, &dyn Expression>,
)
fn write_binary_op( &self, context: &mut Context, out: &mut DynQuery, value: &BinaryOp<&dyn Expression, &dyn Expression>, )
Render binary operator expression handling precedence and parenthesis.
fn write_cast( &self, context: &mut Context, out: &mut DynQuery, expr: &dyn Expression, ty: &dyn Expression, )
Sourcefn write_ordered(
&self,
context: &mut Context,
out: &mut DynQuery,
value: &Ordered<&dyn Expression>,
)
fn write_ordered( &self, context: &mut Context, out: &mut DynQuery, value: &Ordered<&dyn Expression>, )
Render ordered expression inside ORDER BY.
Sourcefn write_join_type(
&self,
_context: &mut Context,
out: &mut DynQuery,
join_type: &JoinType,
)
fn write_join_type( &self, _context: &mut Context, out: &mut DynQuery, join_type: &JoinType, )
Render join keyword(s) for the given join type.
Sourcefn write_join(
&self,
context: &mut Context,
out: &mut DynQuery,
join: &Join<&dyn Dataset, &dyn Dataset, &dyn Expression>,
)
fn write_join( &self, context: &mut Context, out: &mut DynQuery, join: &Join<&dyn Dataset, &dyn Dataset, &dyn Expression>, )
Render a JOIN clause.
Sourcefn write_transaction_begin(&self, out: &mut DynQuery)
fn write_transaction_begin(&self, out: &mut DynQuery)
Emit BEGIN statement.
Sourcefn write_transaction_commit(&self, out: &mut DynQuery)
fn write_transaction_commit(&self, out: &mut DynQuery)
Emit COMMIT statement.
Sourcefn write_transaction_rollback(&self, out: &mut DynQuery)
fn write_transaction_rollback(&self, out: &mut DynQuery)
Emit ROLLBACK statement.
Sourcefn write_create_schema<E>(&self, out: &mut DynQuery, if_not_exists: bool)
fn write_create_schema<E>(&self, out: &mut DynQuery, if_not_exists: bool)
Emit CREATE SCHEMA.
Sourcefn write_drop_schema<E>(&self, out: &mut DynQuery, if_exists: bool)
fn write_drop_schema<E>(&self, out: &mut DynQuery, if_exists: bool)
Emit DROP SCHEMA.
Sourcefn write_create_table<E>(&self, out: &mut DynQuery, if_not_exists: bool)
fn write_create_table<E>(&self, out: &mut DynQuery, if_not_exists: bool)
Emit CREATE TABLE with columns, constraints & comments.
Sourcefn write_create_table_column_fragment(
&self,
context: &mut Context,
out: &mut DynQuery,
column: &ColumnDef,
)where
Self: Sized,
fn write_create_table_column_fragment(
&self,
context: &mut Context,
out: &mut DynQuery,
column: &ColumnDef,
)where
Self: Sized,
Emit single column definition fragment.
Sourcefn write_create_table_primary_key_fragment<'a, It>(
&self,
context: &mut Context,
out: &mut DynQuery,
primary_key: It,
)
fn write_create_table_primary_key_fragment<'a, It>( &self, context: &mut Context, out: &mut DynQuery, primary_key: It, )
Write PRIMARY KEY constraint.
Sourcefn write_create_table_references_action(
&self,
_context: &mut Context,
out: &mut DynQuery,
action: &Action,
)
fn write_create_table_references_action( &self, _context: &mut Context, out: &mut DynQuery, action: &Action, )
Write referential action.
fn write_column_comment_inline(
&self,
_context: &mut Context,
_out: &mut DynQuery,
_column: &ColumnDef,
)where
Self: Sized,
Sourcefn write_column_comments_statements<E>(
&self,
context: &mut Context,
out: &mut DynQuery,
)
fn write_column_comments_statements<E>( &self, context: &mut Context, out: &mut DynQuery, )
Write column comments.
Sourcefn write_drop_table<E>(&self, out: &mut DynQuery, if_exists: bool)
fn write_drop_table<E>(&self, out: &mut DynQuery, if_exists: bool)
Write DROP TABLE statement.
Sourcefn write_select<'a, Data>(
&self,
out: &mut DynQuery,
query: &impl SelectQuery<Data>,
)
fn write_select<'a, Data>( &self, out: &mut DynQuery, query: &impl SelectQuery<Data>, )
Write SELECT statement.
Sourcefn write_insert<'b, E>(
&self,
out: &mut DynQuery,
entities: impl IntoIterator<Item = &'b E>,
update: bool,
)
fn write_insert<'b, E>( &self, out: &mut DynQuery, entities: impl IntoIterator<Item = &'b E>, update: bool, )
Write INSERT statement.
Sourcefn write_insert_update_fragment<'a, E>(
&self,
context: &mut Context,
out: &mut DynQuery,
columns: impl Iterator<Item = &'a ColumnDef> + Clone,
)
fn write_insert_update_fragment<'a, E>( &self, context: &mut Context, out: &mut DynQuery, columns: impl Iterator<Item = &'a ColumnDef> + Clone, )
Write ON CONFLICT DO UPDATE fragment for upsert.
Sourcefn write_delete<E>(&self, out: &mut DynQuery, condition: impl Expression)
fn write_delete<E>(&self, out: &mut DynQuery, condition: impl Expression)
Write DELETE statement.