pub trait Dialect:
Clone
+ Default
+ Send
+ Sync
+ Sized
+ 'static {
const CLASS: &'static str;
const WRAP: char = '`';
const LIKE_ESCAPE: u8 = b'\\';
const DECLARES_LIKE_ESCAPE: bool = false;
const IMPLICIT_LIKE_ESCAPE: Option<u8> = _;
const LITERAL: StringLiteral = crate::StringLiteral::Backslash;
Show 32 methods
// Required methods
fn compile_random(b: &Builder<Self>) -> String;
fn compile_regex(
b: &mut Builder<Self>,
attribute: &str,
values: &Array,
column: Option<&str>,
) -> Result<String>;
// Provided methods
fn quote(_b: &Builder<Self>, identifier: &str) -> Result<String> { ... }
fn quote_string(value: &[u8]) -> Vec<u8> ⓘ { ... }
fn base_step(
_b: &mut Builder<Self>,
_step: Step,
_arguments: &[Arg<'_>],
) -> Option<Result<Ret>> { ... }
fn compile_filter(b: &mut Builder<Self>, query: &Query) -> Result<String> { ... }
fn compile_like(
b: &mut Builder<Self>,
attribute: &str,
values: &Array,
prefix: &str,
suffix: &str,
not: bool,
column: Option<&str>,
) -> Result<String> { ... }
fn compile_contains(
b: &mut Builder<Self>,
attribute: &str,
values: &Array,
column: Option<&str>,
) -> Result<String> { ... }
fn compile_contains_all(
b: &mut Builder<Self>,
attribute: &str,
values: &Array,
column: Option<&str>,
) -> Result<String> { ... }
fn compile_not_contains(
b: &mut Builder<Self>,
attribute: &str,
values: &Array,
column: Option<&str>,
) -> Result<String> { ... }
fn like_keyword(_b: &Builder<Self>) -> &'static str { ... }
fn build_table_clause(b: &mut Builder<Self>) -> Result<String> { ... }
fn build_after_joins_clause(
_b: &mut Builder<Self>,
_grouped: &ParsedQuery,
) -> Result<String> { ... }
fn build_after_group_by_clause(_b: &mut Builder<Self>) -> Result<String> { ... }
fn build_after_order_by_clause(_b: &mut Builder<Self>) -> Result<String> { ... }
fn build_settings_clause(_b: &mut Builder<Self>) -> Result<String> { ... }
fn wrap_union_member(_b: &Builder<Self>, sql: &str) -> String { ... }
fn should_emit_offset(
_b: &Builder<Self>,
offset: Option<i64>,
limit: Option<i64>,
) -> Result<bool> { ... }
fn compile_vector_order_expression(
_b: &mut Builder<Self>,
) -> Result<Option<Condition>> { ... }
fn compile_group_by_time_bucket(
_b: &mut Builder<Self>,
_attribute: &str,
_interval: &str,
) -> Result<String> { ... }
fn resolve_join_filter_placement(
_b: &Builder<Self>,
requested: Placement,
is_cross_join: bool,
) -> Placement { ... }
fn compile_join_with_builder(
b: &mut Builder<Self>,
query: &Query,
join: &JoinBuilder,
) -> Result<String> { ... }
fn build(b: &mut Builder<Self>) -> Result<Statement> { ... }
fn insert(b: &mut Builder<Self>) -> Result<Statement> { ... }
fn insert_default_values(b: &mut Builder<Self>) -> Result<Statement> { ... }
fn update(b: &mut Builder<Self>) -> Result<Statement> { ... }
fn delete(b: &mut Builder<Self>) -> Result<Statement> { ... }
fn explain(
b: &mut Builder<Self>,
analyze: bool,
_options: &ExplainOptions,
) -> Result<Statement> { ... }
fn reset(_b: &mut Builder<Self>) { ... }
fn add_hook(b: &mut Builder<Self>, hook: Hook) -> Result<()> { ... }
fn set(b: &mut Builder<Self>, row: Array) -> Result<()> { ... }
fn ast_dialect() -> AstDialect { ... }
}Expand description
What a dialect changes in the shared compilation: identifier quoting,
random order, regex, and the clauses only some dialects emit. Every hook
has the behaviour of PHP’s base Builder unless the dialect overrides it.
Required Associated Constants§
Provided Associated Constants§
Sourceconst LIKE_ESCAPE: u8 = b'\\'
const LIKE_ESCAPE: u8 = b'\\'
The character that escapes %, _ and itself in a LIKE pattern.
PHP: LIKE_ESCAPE.
Sourceconst DECLARES_LIKE_ESCAPE: bool = false
const DECLARES_LIKE_ESCAPE: bool = false
Whether a LIKE names its escape character (LIKE ? ESCAPE '!').
PHP: DECLARES_LIKE_ESCAPE.
Sourceconst IMPLICIT_LIKE_ESCAPE: Option<u8> = _
const IMPLICIT_LIKE_ESCAPE: Option<u8> = _
The character LIKE escapes with when a pattern declares none; None when it escapes
nothing, as in SQLite.
PHP: IMPLICIT_LIKE_ESCAPE.
Sourceconst LITERAL: StringLiteral = crate::StringLiteral::Backslash
const LITERAL: StringLiteral = crate::StringLiteral::Backslash
How the dialect writes and reads a string literal.
PHP: $literal.
Required Methods§
Sourcefn compile_random(b: &Builder<Self>) -> String
fn compile_random(b: &Builder<Self>) -> String
The random-order expression (RAND()).
Provided Methods§
Sourcefn quote(_b: &Builder<Self>, identifier: &str) -> Result<String>
fn quote(_b: &Builder<Self>, identifier: &str) -> Result<String>
Quotes an identifier (`users`.`id`).
Sourcefn quote_string(value: &[u8]) -> Vec<u8> ⓘ
fn quote_string(value: &[u8]) -> Vec<u8> ⓘ
A string literal for to_raw_sql(): \ doubled and ' doubled
(PostgreSQL and SQLite double only ', since \ is not an escape
in their standard strings).
PHP: quoteString().
Sourcefn base_step(
_b: &mut Builder<Self>,
_step: Step,
_arguments: &[Arg<'_>],
) -> Option<Result<Ret>>
fn base_step( _b: &mut Builder<Self>, _step: Step, _arguments: &[Arg<'_>], ) -> Option<Result<Ret>>
A step only some dialects have, run as the dialect itself does: None where the
dialect has no such step.
Sourcefn compile_filter(b: &mut Builder<Self>, query: &Query) -> Result<String>
fn compile_filter(b: &mut Builder<Self>, query: &Query) -> Result<String>
A filter query (the base compiles comparisons, LIKE, IN, logical and raw filters).
Sourcefn compile_like(
b: &mut Builder<Self>,
attribute: &str,
values: &Array,
prefix: &str,
suffix: &str,
not: bool,
column: Option<&str>,
) -> Result<String>
fn compile_like( b: &mut Builder<Self>, attribute: &str, values: &Array, prefix: &str, suffix: &str, not: bool, column: Option<&str>, ) -> Result<String>
LIKE with a prefix and suffix around the escaped value.
Sourcefn compile_contains(
b: &mut Builder<Self>,
attribute: &str,
values: &Array,
column: Option<&str>,
) -> Result<String>
fn compile_contains( b: &mut Builder<Self>, attribute: &str, values: &Array, column: Option<&str>, ) -> Result<String>
contains (LIKE '%v%', ORed for several values).
Sourcefn compile_contains_all(
b: &mut Builder<Self>,
attribute: &str,
values: &Array,
column: Option<&str>,
) -> Result<String>
fn compile_contains_all( b: &mut Builder<Self>, attribute: &str, values: &Array, column: Option<&str>, ) -> Result<String>
containsAll (LIKE '%v%', ANDed).
Sourcefn compile_not_contains(
b: &mut Builder<Self>,
attribute: &str,
values: &Array,
column: Option<&str>,
) -> Result<String>
fn compile_not_contains( b: &mut Builder<Self>, attribute: &str, values: &Array, column: Option<&str>, ) -> Result<String>
notContains (NOT LIKE '%v%', ANDed).
Sourcefn like_keyword(_b: &Builder<Self>) -> &'static str
fn like_keyword(_b: &Builder<Self>) -> &'static str
The LIKE keyword (ILIKE on PostgreSQL).
Sourcefn build_table_clause(b: &mut Builder<Self>) -> Result<String>
fn build_table_clause(b: &mut Builder<Self>) -> Result<String>
The FROM clause.
Sourcefn build_after_joins_clause(
_b: &mut Builder<Self>,
_grouped: &ParsedQuery,
) -> Result<String>
fn build_after_joins_clause( _b: &mut Builder<Self>, _grouped: &ParsedQuery, ) -> Result<String>
Clauses after the joins and before WHERE (ClickHouse ARRAY JOIN, PREWHERE).
Sourcefn build_after_group_by_clause(_b: &mut Builder<Self>) -> Result<String>
fn build_after_group_by_clause(_b: &mut Builder<Self>) -> Result<String>
Clauses after GROUP BY (ClickHouse WITH TOTALS).
Sourcefn build_after_order_by_clause(_b: &mut Builder<Self>) -> Result<String>
fn build_after_order_by_clause(_b: &mut Builder<Self>) -> Result<String>
Clauses after ORDER BY (ClickHouse LIMIT BY).
Sourcefn build_settings_clause(_b: &mut Builder<Self>) -> Result<String>
fn build_settings_clause(_b: &mut Builder<Self>) -> Result<String>
Clauses at the very end of a select (ClickHouse SETTINGS).
Sourcefn wrap_union_member(_b: &Builder<Self>, sql: &str) -> String
fn wrap_union_member(_b: &Builder<Self>, sql: &str) -> String
One member of a UNION chain (parenthesised by default).
Sourcefn should_emit_offset(
_b: &Builder<Self>,
offset: Option<i64>,
limit: Option<i64>,
) -> Result<bool>
fn should_emit_offset( _b: &Builder<Self>, offset: Option<i64>, limit: Option<i64>, ) -> Result<bool>
Whether to emit OFFSET; the base refuses an offset without a limit.
Sourcefn compile_vector_order_expression(
_b: &mut Builder<Self>,
) -> Result<Option<Condition>>
fn compile_vector_order_expression( _b: &mut Builder<Self>, ) -> Result<Option<Condition>>
An ORDER BY vector distance expression (PostgreSQL).
Sourcefn compile_group_by_time_bucket(
_b: &mut Builder<Self>,
_attribute: &str,
_interval: &str,
) -> Result<String>
fn compile_group_by_time_bucket( _b: &mut Builder<Self>, _attribute: &str, _interval: &str, ) -> Result<String>
A groupByTimeBucket expression; unsupported by default.
Sourcefn resolve_join_filter_placement(
_b: &Builder<Self>,
requested: Placement,
is_cross_join: bool,
) -> Placement
fn resolve_join_filter_placement( _b: &Builder<Self>, requested: Placement, is_cross_join: bool, ) -> Placement
Where a join filter’s condition goes (cross and natural joins have no ON).
Sourcefn compile_join_with_builder(
b: &mut Builder<Self>,
query: &Query,
join: &JoinBuilder,
) -> Result<String>
fn compile_join_with_builder( b: &mut Builder<Self>, query: &Query, join: &JoinBuilder, ) -> Result<String>
The ON of a join built with a JoinBuilder.
Sourcefn insert_default_values(b: &mut Builder<Self>) -> Result<Statement>
fn insert_default_values(b: &mut Builder<Self>) -> Result<Statement>
INSERT ... DEFAULT VALUES.
Sourcefn explain(
b: &mut Builder<Self>,
analyze: bool,
_options: &ExplainOptions,
) -> Result<Statement>
fn explain( b: &mut Builder<Self>, analyze: bool, _options: &ExplainOptions, ) -> Result<Statement>
EXPLAIN of the select statement.
Sourcefn reset(_b: &mut Builder<Self>)
fn reset(_b: &mut Builder<Self>)
Clears the dialect’s own state (after the shared state is cleared).
Sourcefn set(b: &mut Builder<Self>, row: Array) -> Result<()>
fn set(b: &mut Builder<Self>, row: Array) -> Result<()>
Adds a row to insert or the values to update.
Sourcefn ast_dialect() -> AstDialect
fn ast_dialect() -> AstDialect
The serializer fromAst/toAst use for expressions.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".