pub struct Builder<D: Dialect> { /* private fields */ }Expand description
A query builder for one dialect: from a table, with queries (filters,
ordering, pagination, aggregates, joins) and the builder’s own clauses
(subqueries, raw SQL, window functions, CTEs, unions), compiled by
Builder::build into a Statement; also inserts, updates, deletes and
upserts.
The dialects are type aliases: MySql and the
others. Features only some dialects have are traits in
feature.
PHP: the abstract Utopia\Query\Builder and its subclasses.
Implementations§
Source§impl<D: Dialect> Builder<D>
impl<D: Dialect> Builder<D>
Sourcepub fn from(
&mut self,
table: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn from( &mut self, table: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
The table (and its alias) to select from, update or delete from; an
empty table makes a select without FROM.
PHP: from($table, $alias).
On a builder with a Scope, a non-empty
table is a collection id read through the scope (see
Builder::scope).
Sourcepub fn take_refusal(&mut self) -> Option<Error>
pub fn take_refusal(&mut self) -> Option<Error>
The refusal a call returning the builder kept for the next
statement, taken: PHP throws it from that call (from() of another
collection or alias on a bound builder, into() and the dialects’
multi-table writes once a collection is bound).
PHP: ScopesCollections::from(), requireUnbound().
Sourcepub fn from_sub(
&mut self,
subquery: impl AnyBuilder + 'static,
alias: impl Into<String>,
) -> &mut Self
pub fn from_sub( &mut self, subquery: impl AnyBuilder + 'static, alias: impl Into<String>, ) -> &mut Self
FROM (subquery) AS alias.
PHP: fromSub().
Sourcepub fn from_sub_boxed(
&mut self,
subquery: Box<dyn AnyBuilder>,
alias: impl Into<String>,
) -> &mut Self
pub fn from_sub_boxed( &mut self, subquery: Box<dyn AnyBuilder>, alias: impl Into<String>, ) -> &mut Self
Builder::from_sub with a boxed builder.
Sourcepub fn select_sub(
&mut self,
subquery: Box<dyn AnyBuilder>,
alias: impl Into<String>,
) -> &mut Self
pub fn select_sub( &mut self, subquery: Box<dyn AnyBuilder>, alias: impl Into<String>, ) -> &mut Self
(subquery) AS alias in the select list.
PHP: selectSub().
Sourcepub fn filter_where_in(
&mut self,
column: impl Into<String>,
subquery: Box<dyn AnyBuilder>,
) -> &mut Self
pub fn filter_where_in( &mut self, column: impl Into<String>, subquery: Box<dyn AnyBuilder>, ) -> &mut Self
column IN (subquery).
PHP: filterWhereIn().
Sourcepub fn filter_where_not_in(
&mut self,
column: impl Into<String>,
subquery: Box<dyn AnyBuilder>,
) -> &mut Self
pub fn filter_where_not_in( &mut self, column: impl Into<String>, subquery: Box<dyn AnyBuilder>, ) -> &mut Self
column NOT IN (subquery).
PHP: filterWhereNotIn().
Sourcepub fn filter_exists(&mut self, subquery: Box<dyn AnyBuilder>) -> &mut Self
pub fn filter_exists(&mut self, subquery: Box<dyn AnyBuilder>) -> &mut Self
EXISTS (subquery).
PHP: filterExists().
Sourcepub fn filter_not_exists(&mut self, subquery: Box<dyn AnyBuilder>) -> &mut Self
pub fn filter_not_exists(&mut self, subquery: Box<dyn AnyBuilder>) -> &mut Self
NOT EXISTS (subquery).
PHP: filterNotExists().
Sourcepub fn select<S: Into<String>>(
&mut self,
columns: impl IntoIterator<Item = S>,
) -> &mut Self
pub fn select<S: Into<String>>( &mut self, columns: impl IntoIterator<Item = S>, ) -> &mut Self
The columns to select.
PHP: select(array $columns).
Sourcepub fn select_raw(
&mut self,
expression: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn select_raw( &mut self, expression: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
A raw select expression with its bindings.
PHP: select(string $expression, $bindings), selectRaw().
Sourcepub fn filter(&mut self, queries: impl IntoIterator<Item = Query>) -> &mut Self
pub fn filter(&mut self, queries: impl IntoIterator<Item = Query>) -> &mut Self
Adds queries (filters, or any query).
PHP: filter().
Sourcepub fn queries(&mut self, queries: impl IntoIterator<Item = Query>) -> &mut Self
pub fn queries(&mut self, queries: impl IntoIterator<Item = Query>) -> &mut Self
Adds queries of any kind.
PHP: queries().
Sourcepub fn sort_asc(
&mut self,
attribute: impl Into<String>,
nulls: Option<NullsPosition>,
) -> &mut Self
pub fn sort_asc( &mut self, attribute: impl Into<String>, nulls: Option<NullsPosition>, ) -> &mut Self
ORDER BY attribute ASC (with NULLS FIRST/LAST).
PHP: sortAsc().
Sourcepub fn sort_desc(
&mut self,
attribute: impl Into<String>,
nulls: Option<NullsPosition>,
) -> &mut Self
pub fn sort_desc( &mut self, attribute: impl Into<String>, nulls: Option<NullsPosition>, ) -> &mut Self
ORDER BY attribute DESC (with NULLS FIRST/LAST).
PHP: sortDesc().
Sourcepub fn sort_random(&mut self) -> &mut Self
pub fn sort_random(&mut self) -> &mut Self
Random order.
PHP: sortRandom().
Sourcepub fn fetch(&mut self, count: i64, with_ties: bool) -> &mut Self
pub fn fetch(&mut self, count: i64, with_ties: bool) -> &mut Self
FETCH FIRST count ROWS ONLY (or WITH TIES).
PHP: fetch().
Sourcepub fn page(&mut self, page: i64, per_page: i64) -> Result<&mut Self>
pub fn page(&mut self, page: i64, per_page: i64) -> Result<&mut Self>
The limit and offset of page page (from 1) of per_page rows.
PHP: page().
Sourcepub fn cursor_after(&mut self, row: Value) -> &mut Self
pub fn cursor_after(&mut self, row: Value) -> &mut Self
Rows after a cursor row (an array with _cursor, or a row object).
PHP: cursorAfter().
Sourcepub fn cursor_before(&mut self, row: Value) -> &mut Self
pub fn cursor_before(&mut self, row: Value) -> &mut Self
Rows before a cursor row.
PHP: cursorBefore().
Sourcepub fn when(
&mut self,
condition: bool,
callback: impl FnOnce(&mut Self) -> Result<()>,
) -> Result<&mut Self>
pub fn when( &mut self, condition: bool, callback: impl FnOnce(&mut Self) -> Result<()>, ) -> Result<&mut Self>
Runs callback with the builder when condition holds.
PHP: when().
Sourcepub fn before_build(
&mut self,
callback: impl Fn(&mut Self) -> Result<()> + Send + Sync + 'static,
) -> &mut Self
pub fn before_build( &mut self, callback: impl Fn(&mut Self) -> Result<()> + Send + Sync + 'static, ) -> &mut Self
A callback run with the builder at the start of every build.
PHP: beforeBuild().
Sourcepub fn after_build(
&mut self,
callback: impl Fn(Statement) -> Result<Statement> + Send + Sync + 'static,
) -> &mut Self
pub fn after_build( &mut self, callback: impl Fn(Statement) -> Result<Statement> + Send + Sync + 'static, ) -> &mut Self
A callback run on every built statement, returning the statement to use.
PHP: afterBuild().
Sourcepub fn after_build_owned(
&mut self,
callback: impl Fn(usize, Statement) -> Result<Statement> + Send + Sync + 'static,
) -> &mut Self
pub fn after_build_owned( &mut self, callback: impl Fn(usize, Statement) -> Result<Statement> + Send + Sync + 'static, ) -> &mut Self
As Self::after_build, with the owner of the builder that built.
Sourcepub fn set_executor(&mut self, executor: Executor) -> &mut Self
pub fn set_executor(&mut self, executor: Executor) -> &mut Self
What runs the statements this builder builds (Builder::execute).
PHP: setExecutor().
Sourcepub fn explain(&mut self, analyze: bool) -> Result<Statement>
pub fn explain(&mut self, analyze: bool) -> Result<Statement>
EXPLAIN (or EXPLAIN ANALYZE) of the select.
PHP: explain($analyze).
Sourcepub fn explain_with(
&mut self,
analyze: bool,
options: &ExplainOptions,
) -> Result<Statement>
pub fn explain_with( &mut self, analyze: bool, options: &ExplainOptions, ) -> Result<Statement>
EXPLAIN with the dialect’s options (format; PostgreSQL’s verbose and buffers).
PHP: explain($analyze, ...) of MySQL and PostgreSQL.
Sourcepub fn execute(&mut self) -> Result<Value>
pub fn execute(&mut self) -> Result<Value>
Builds the select and runs it with the executor.
PHP: execute().
Sourcepub fn to_raw_sql(&mut self) -> Result<String>
pub fn to_raw_sql(&mut self) -> Result<String>
The select with its bindings inlined: strings quoted by the dialect
(' doubled, and \ doubled outside PostgreSQL and SQLite),
numbers as PHP prints them, booleans as 1/0, anything else NULL.
For logs only: never execute it.
PHP: toRawSql().
Sourcepub fn to_raw_sql_widened(&mut self) -> Result<String>
pub fn to_raw_sql_widened(&mut self) -> Result<String>
As Builder::to_raw_sql, for a builder whose text holds a character for each
byte, as the PHP extension passes a string that is not UTF-8: the bytes of a
string binding are written the same way.
Sourcepub fn binding_list(&self) -> &[Binding]
pub fn binding_list(&self) -> &[Binding]
The bindings so far, each with the column it was bound against.
PHP: the protected $bindings.
Sourcepub fn set_binding_list(&mut self, bindings: Vec<Binding>) -> &mut Self
pub fn set_binding_list(&mut self, bindings: Vec<Binding>) -> &mut Self
Replaces the bindings.
Sourcepub fn set_pending(&mut self, queries: Vec<Query>) -> &mut Self
pub fn set_pending(&mut self, queries: Vec<Query>) -> &mut Self
Replaces the queries to compile.
PHP: the protected $pendingQueries.
Sourcepub fn resolved_attributes(&self) -> impl Iterator<Item = (&str, &str)>
pub fn resolved_attributes(&self) -> impl Iterator<Item = (&str, &str)>
The attributes resolved so far, and what each resolved to.
PHP: the protected $resolvedAttributeCache.
Sourcepub fn set_resolved_attributes(
&mut self,
resolved: impl IntoIterator<Item = (String, String)>,
) -> &mut Self
pub fn set_resolved_attributes( &mut self, resolved: impl IntoIterator<Item = (String, String)>, ) -> &mut Self
Replaces the resolved attributes.
Sourcepub fn bindings(&mut self) -> Vec<Value>
pub fn bindings(&mut self) -> Vec<Value>
The bindings of the last statement built.
PHP: getBindings().
Sourcepub fn reset(&mut self) -> &mut Self
pub fn reset(&mut self) -> &mut Self
Clears everything but hooks and the executor.
PHP: reset().
Sourcepub fn count(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn count( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
count(attribute) (* counts rows) as alias.
PHP: count().
Sourcepub fn count_distinct(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn count_distinct( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
COUNT(DISTINCT attribute).
PHP: countDistinct().
Sourcepub fn sum(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn sum( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
SUM.
PHP: sum().
Sourcepub fn avg(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn avg( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
AVG.
PHP: avg().
Sourcepub fn min(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn min( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
MIN.
PHP: min().
Sourcepub fn max(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn max( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
MAX.
PHP: max().
Sourcepub fn group_by<S: Into<String>>(
&mut self,
columns: impl IntoIterator<Item = S>,
) -> &mut Self
pub fn group_by<S: Into<String>>( &mut self, columns: impl IntoIterator<Item = S>, ) -> &mut Self
GROUP BY.
PHP: groupBy().
Sourcepub fn group_by_time_bucket(
&mut self,
attribute: impl Into<String>,
interval: &str,
) -> Result<&mut Self>
pub fn group_by_time_bucket( &mut self, attribute: impl Into<String>, interval: &str, ) -> Result<&mut Self>
Groups by attribute cut into windows of interval.
PHP: groupByTimeBucket().
Sourcepub fn having(&mut self, queries: impl IntoIterator<Item = Query>) -> &mut Self
pub fn having(&mut self, queries: impl IntoIterator<Item = Query>) -> &mut Self
HAVING conditions (aggregate aliases resolve to their expressions).
PHP: having().
Sourcepub fn join(
&mut self,
table: impl Into<String>,
left: &str,
right: &str,
operator: &str,
alias: impl Into<String>,
) -> &mut Self
pub fn join( &mut self, table: impl Into<String>, left: &str, right: &str, operator: &str, alias: impl Into<String>, ) -> &mut Self
JOIN table [AS alias] ON left operator right.
PHP: join().
Sourcepub fn left_join(
&mut self,
table: impl Into<String>,
left: &str,
right: &str,
operator: &str,
alias: impl Into<String>,
) -> &mut Self
pub fn left_join( &mut self, table: impl Into<String>, left: &str, right: &str, operator: &str, alias: impl Into<String>, ) -> &mut Self
LEFT JOIN.
PHP: leftJoin().
Sourcepub fn right_join(
&mut self,
table: impl Into<String>,
left: &str,
right: &str,
operator: &str,
alias: impl Into<String>,
) -> &mut Self
pub fn right_join( &mut self, table: impl Into<String>, left: &str, right: &str, operator: &str, alias: impl Into<String>, ) -> &mut Self
RIGHT JOIN.
PHP: rightJoin().
Sourcepub fn join_where(
&mut self,
table: impl Into<String>,
callback: impl FnOnce(&mut JoinBuilder) -> Result<()>,
join_type: JoinType,
alias: impl Into<String>,
) -> Result<&mut Self>
pub fn join_where( &mut self, table: impl Into<String>, callback: impl FnOnce(&mut JoinBuilder) -> Result<()>, join_type: JoinType, alias: impl Into<String>, ) -> Result<&mut Self>
A join whose conditions callback builds on a JoinBuilder.
PHP: joinWhere().
Sourcepub fn union(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
pub fn union(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
UNION with another builder’s select (built now).
PHP: union().
Sourcepub fn union_all(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
pub fn union_all(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
UNION ALL.
PHP: unionAll().
Sourcepub fn intersect(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
pub fn intersect(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
INTERSECT.
PHP: intersect().
Sourcepub fn intersect_all(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
pub fn intersect_all(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
INTERSECT ALL.
PHP: intersectAll().
Sourcepub fn except(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
pub fn except(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
EXCEPT.
PHP: except().
Sourcepub fn except_all(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
pub fn except_all(&mut self, other: &mut dyn AnyBuilder) -> Result<&mut Self>
EXCEPT ALL.
PHP: exceptAll().
Sourcepub fn with<S: Into<String>>(
&mut self,
name: impl Into<String>,
query: &mut dyn AnyBuilder,
columns: impl IntoIterator<Item = S>,
) -> Result<&mut Self>
pub fn with<S: Into<String>>( &mut self, name: impl Into<String>, query: &mut dyn AnyBuilder, columns: impl IntoIterator<Item = S>, ) -> Result<&mut Self>
WITH name [(columns)] AS (query) (built now).
PHP: with().
Sourcepub fn with_recursive<S: Into<String>>(
&mut self,
name: impl Into<String>,
query: &mut dyn AnyBuilder,
columns: impl IntoIterator<Item = S>,
) -> Result<&mut Self>
pub fn with_recursive<S: Into<String>>( &mut self, name: impl Into<String>, query: &mut dyn AnyBuilder, columns: impl IntoIterator<Item = S>, ) -> Result<&mut Self>
WITH RECURSIVE name AS (query).
PHP: withRecursive().
Sourcepub fn with_recursive_seed_step<S: Into<String>>(
&mut self,
name: impl Into<String>,
seed: &mut dyn AnyBuilder,
step: &mut dyn AnyBuilder,
columns: impl IntoIterator<Item = S>,
) -> Result<&mut Self>
pub fn with_recursive_seed_step<S: Into<String>>( &mut self, name: impl Into<String>, seed: &mut dyn AnyBuilder, step: &mut dyn AnyBuilder, columns: impl IntoIterator<Item = S>, ) -> Result<&mut Self>
WITH RECURSIVE name AS (seed UNION ALL step).
PHP: withRecursiveSeedStep().
Sourcepub fn into(&mut self, table: impl Into<String>) -> &mut Self
pub fn into(&mut self, table: impl Into<String>) -> &mut Self
The table to insert into.
PHP: into().
Sourcepub fn insert_as(&mut self, alias: impl Into<String>) -> &mut Self
pub fn insert_as(&mut self, alias: impl Into<String>) -> &mut Self
INSERT INTO table AS alias.
PHP: insertAs().
Sourcepub fn set(&mut self, row: Array) -> Result<&mut Self>
pub fn set(&mut self, row: Array) -> Result<&mut Self>
A row to insert (column => value), or the values of an update.
PHP: set().
Sourcepub fn on_conflict<K: Into<String>, U: Into<String>>(
&mut self,
keys: impl IntoIterator<Item = K>,
update_columns: impl IntoIterator<Item = U>,
) -> &mut Self
pub fn on_conflict<K: Into<String>, U: Into<String>>( &mut self, keys: impl IntoIterator<Item = K>, update_columns: impl IntoIterator<Item = U>, ) -> &mut Self
The conflict target and the columns an upsert updates.
PHP: onConflict().
Sourcepub fn from_select<S: Into<String>>(
&mut self,
columns: impl IntoIterator<Item = S>,
source: Box<dyn AnyBuilder>,
) -> &mut Self
pub fn from_select<S: Into<String>>( &mut self, columns: impl IntoIterator<Item = S>, source: Box<dyn AnyBuilder>, ) -> &mut Self
INSERT INTO table (columns) SELECT ... from source (built at insert time).
PHP: fromSelect().
Sourcepub fn insert_default_values(&mut self) -> Result<Statement>
pub fn insert_default_values(&mut self) -> Result<Statement>
INSERT INTO table DEFAULT VALUES (MySQL: () VALUES ()).
PHP: insertDefaultValues().
Sourcepub fn insert_select(&mut self) -> Result<Statement>
pub fn insert_select(&mut self) -> Result<Statement>
INSERT INTO table (columns) SELECT ....
PHP: insertSelect().
Sourcepub fn add_hook(&mut self, hook: impl Into<Hook>) -> Result<&mut Self>
pub fn add_hook(&mut self, hook: impl Into<Hook>) -> Result<&mut Self>
Adds a hook: a filter, an attribute resolver, a join filter, or several at once.
PHP: addHook().
Sourcepub fn select_window(
&mut self,
function: impl Into<String>,
alias: impl Into<String>,
partition_by: Option<Vec<String>>,
order_by: Option<Vec<String>>,
window_name: Option<String>,
frame: Option<WindowFrame>,
) -> Result<&mut Self>
pub fn select_window( &mut self, function: impl Into<String>, alias: impl Into<String>, partition_by: Option<Vec<String>>, order_by: Option<Vec<String>>, window_name: Option<String>, frame: Option<WindowFrame>, ) -> Result<&mut Self>
A window function in the select list: function OVER (...) AS alias,
or OVER window_name. The function must look like NAME(args).
PHP: selectWindow().
Source§impl<D: Dialect> Builder<D>
impl<D: Dialect> Builder<D>
Sourcepub fn to_ast(&mut self) -> Result<Select>
pub fn to_ast(&mut self) -> Result<Select>
The builder’s select as a syntax tree: columns and aggregates,
table, joins, filters, grouping, HAVING, ordering, limit, offset,
DISTINCT and CTEs (each CTE’s SQL parsed with the standard tokenizer).
PHP: Builder::toAst().
Sourcepub fn from_ast(select: &Select) -> Result<Self>
pub fn from_ast(select: &Select) -> Result<Self>
A builder with the select select describes: its table, columns
(aggregates become aggregate queries, other expressions raw selects),
joins, filters, grouping, HAVING, ordering, limit, offset, CTEs and
DISTINCT. Expressions without a query equivalent are kept as raw
SQL, written by the dialect’s serializer.
PHP: Builder::fromAst().
Sourcepub fn from_ast_with(select: &Select, writer: &dyn AstWriter) -> Result<Self>
pub fn from_ast_with(select: &Select, writer: &dyn AstWriter) -> Result<Self>
Self::from_ast, writing what stays raw SQL with writer.
PHP: fromAst() in a subclass that overrides createAstSerializer().
Source§impl Builder<ClickHouseDialect>
impl Builder<ClickHouseDialect>
Sourcepub fn apply_named_typed_bindings(&self, statement: Statement) -> Statement
pub fn apply_named_typed_bindings(&self, statement: Statement) -> Statement
statement with its ? placeholders named and typed, when named bindings are on.
PHP: applyNamedTypedBindings().
Source§impl Builder<ClickHouseDialect>
impl Builder<ClickHouseDialect>
Sourcepub fn prewhere(
&mut self,
queries: impl IntoIterator<Item = Query>,
) -> &mut Self
pub fn prewhere( &mut self, queries: impl IntoIterator<Item = Query>, ) -> &mut Self
PREWHERE filters, evaluated before the other columns are read.
PHP: prewhere().
Sourcepub fn final_(&mut self) -> &mut Self
pub fn final_(&mut self) -> &mut Self
FINAL after the table (merges the data parts first).
PHP: final().
Sourcepub fn sample(&mut self, fraction: f64) -> Result<&mut Self>
pub fn sample(&mut self, fraction: f64) -> Result<&mut Self>
SAMPLE fraction after the table; the fraction must be in (0, 1).
PHP: sample().
Sourcepub fn settings<K: AsRef<str>, V: AsRef<str>>(
&mut self,
settings: impl IntoIterator<Item = (K, V)>,
) -> Result<&mut Self>
pub fn settings<K: AsRef<str>, V: AsRef<str>>( &mut self, settings: impl IntoIterator<Item = (K, V)>, ) -> Result<&mut Self>
SETTINGS key=value, ... at the end of selects and deletes; keys are
identifiers, values letters, digits, _ and ..
PHP: settings().
Sourcepub fn bulk_insert(
&mut self,
format: Format,
rows: impl IntoIterator<Item = Value>,
columns: Vec<String>,
) -> Result<FormattedInsertStatement>
pub fn bulk_insert( &mut self, format: Format, rows: impl IntoIterator<Item = Value>, columns: Vec<String>, ) -> Result<FormattedInsertStatement>
The INSERT INTO table [(columns)] FORMAT format envelope with the
rows serialized in format. Each row must be an array; the columns
default to the first row’s keys.
PHP: bulkInsert().
use utopia_query::builder::{ClickHouse, Format};
use utopia_query::{Array, Value};
let mut row = Array::default();
row.set("id".into(), Value::Int(1));
let insert = ClickHouse::new().from("events", "").bulk_insert(Format::JSONEachRow, [Value::Array(row)], Vec::new())?;
assert_eq!(insert.query, "INSERT INTO `events` (`id`) FORMAT JSONEachRow");
assert_eq!(insert.body.as_deref(), Some(r#"{"id":1}"#));use Utopia\Query\Builder\ClickHouse;
use Utopia\Query\Builder\ClickHouse\Format;
$insert = (new ClickHouse())->from('events')->bulkInsert(Format::JSONEachRow, [['id' => 1]]);
echo $insert->query, "\n", $insert->body, "\n";
// INSERT INTO `events` (`id`) FORMAT JSONEachRow
// {"id":1}Sourcepub fn insert_format<S: Into<String>>(
&mut self,
format: &str,
columns: impl IntoIterator<Item = S>,
) -> Result<&mut Self>
pub fn insert_format<S: Into<String>>( &mut self, format: &str, columns: impl IntoIterator<Item = S>, ) -> Result<&mut Self>
Makes Builder::insert (and Builder::formatted_insert) emit the
FORMAT format envelope only, for a body sent separately; the columns
default to the keys of the first row set.
PHP: insertFormat().
Sourcepub fn formatted_insert(&mut self) -> Result<Option<FormattedInsertStatement>>
pub fn formatted_insert(&mut self) -> Result<Option<FormattedInsertStatement>>
The FORMAT envelope of an Builder::insert_format insert (with no
body), or None when no format was set.
PHP: insert(), which returns a FormattedInsertStatement after insertFormat().
Sourcepub fn use_named_bindings(&mut self, enabled: bool) -> &mut Self
pub fn use_named_bindings(&mut self, enabled: bool) -> &mut Self
Rewrites the ? placeholders of built statements to ClickHouse’s
{paramN:Type} and fills Statement::named_bindings.
PHP: useNamedBindings().
use utopia_query::Query;
use utopia_query::builder::ClickHouse;
let statement = ClickHouse::new()
.use_named_bindings(true)
.with_param_type("time", "DateTime64(3)")?
.from("events", "")
.filter([Query::greater_than("time", "2024-01-01 00:00:00"), Query::less_than_equal("value", 100)])
.build()?;
assert_eq!(
statement.query,
"SELECT * FROM `events` WHERE `time` > {param0:DateTime64(3)} AND `value` <= {param1:Int64}"
);use Utopia\Query\Builder\ClickHouse;
use Utopia\Query\Query;
echo (new ClickHouse())
->useNamedBindings()
->withParamType('time', 'DateTime64(3)')
->from('events')
->filter([Query::greaterThan('time', '2024-01-01 00:00:00'), Query::lessThanEqual('value', 100)])
->build()->query, "\n";
// SELECT * FROM `events` WHERE `time` > {param0:DateTime64(3)} AND `value` <= {param1:Int64}Sourcepub fn with_param_type(
&mut self,
column: impl Into<String>,
type_name: &str,
) -> Result<&mut Self>
pub fn with_param_type( &mut self, column: impl Into<String>, type_name: &str, ) -> Result<&mut Self>
The ClickHouse type of the named placeholders bound against column
(others are inferred: Int64, Float64, UInt8, Nullable(String),
String).
PHP: withParamType().
Sourcepub fn with_param_types<K: Into<String>, V: AsRef<str>>(
&mut self,
types: impl IntoIterator<Item = (K, V)>,
) -> Result<&mut Self>
pub fn with_param_types<K: Into<String>, V: AsRef<str>>( &mut self, types: impl IntoIterator<Item = (K, V)>, ) -> Result<&mut Self>
Builder::with_param_type for each pair.
PHP: withParamTypes().
Sourcepub fn delete_mode(&mut self, mode: DeleteMode) -> &mut Self
pub fn delete_mode(&mut self, mode: DeleteMode) -> &mut Self
Which DELETE form Builder::delete emits.
PHP: deleteMode() (with the mode’s name; see DeleteMode::parse).
Sourcepub fn stddev(&mut self, attribute: &str, alias: &str) -> Result<&mut Self>
pub fn stddev(&mut self, attribute: &str, alias: &str) -> Result<&mut Self>
stddevPop(column) [AS alias]: ClickHouse has no bare STDDEV.
PHP: stddev().
Sourcepub fn stddev_pop(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn stddev_pop( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
STDDEV_POP (as an aggregate query).
PHP: stddevPop().
Sourcepub fn stddev_samp(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn stddev_samp( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
STDDEV_SAMP (as an aggregate query).
PHP: stddevSamp().
Sourcepub fn variance(&mut self, attribute: &str, alias: &str) -> Result<&mut Self>
pub fn variance(&mut self, attribute: &str, alias: &str) -> Result<&mut Self>
varPop(column) [AS alias]: ClickHouse has no bare VARIANCE.
PHP: variance().
Sourcepub fn var_pop(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn var_pop( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
VAR_POP (as an aggregate query).
PHP: varPop().
Sourcepub fn var_samp(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn var_samp( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
VAR_SAMP (as an aggregate query).
PHP: varSamp().
Sourcepub fn quantile(
&mut self,
level: f64,
column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn quantile( &mut self, level: f64, column: &str, alias: &str, ) -> Result<&mut Self>
quantile(level)(column).
PHP: quantile().
Sourcepub fn quantiles(
&mut self,
levels: &[f64],
column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn quantiles( &mut self, levels: &[f64], column: &str, alias: &str, ) -> Result<&mut Self>
quantiles(level, ...)(column); levels must be in [0, 1].
PHP: quantiles().
Sourcepub fn quantile_exact(
&mut self,
level: f64,
column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn quantile_exact( &mut self, level: f64, column: &str, alias: &str, ) -> Result<&mut Self>
quantileExact(level)(column).
PHP: quantileExact().
Sourcepub fn median(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn median(&mut self, column: &str, alias: &str) -> Result<&mut Self>
median(column).
PHP: median().
Sourcepub fn uniq(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn uniq(&mut self, column: &str, alias: &str) -> Result<&mut Self>
uniq(column).
PHP: uniq().
Sourcepub fn uniq_exact(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn uniq_exact(&mut self, column: &str, alias: &str) -> Result<&mut Self>
uniqExact(column).
PHP: uniqExact().
Sourcepub fn uniq_combined(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn uniq_combined(&mut self, column: &str, alias: &str) -> Result<&mut Self>
uniqCombined(column).
PHP: uniqCombined().
Sourcepub fn arg_min(
&mut self,
value_column: &str,
arg_column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn arg_min( &mut self, value_column: &str, arg_column: &str, alias: &str, ) -> Result<&mut Self>
argMin(value, arg).
PHP: argMin().
Sourcepub fn arg_max(
&mut self,
value_column: &str,
arg_column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn arg_max( &mut self, value_column: &str, arg_column: &str, alias: &str, ) -> Result<&mut Self>
argMax(value, arg).
PHP: argMax().
Sourcepub fn top_k(&mut self, k: i64, column: &str, alias: &str) -> Result<&mut Self>
pub fn top_k(&mut self, k: i64, column: &str, alias: &str) -> Result<&mut Self>
topK(k)(column).
PHP: topK().
Sourcepub fn top_k_weighted(
&mut self,
k: i64,
column: &str,
weight_column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn top_k_weighted( &mut self, k: i64, column: &str, weight_column: &str, alias: &str, ) -> Result<&mut Self>
topKWeighted(k)(column, weight).
PHP: topKWeighted().
Sourcepub fn any_value(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn any_value(&mut self, column: &str, alias: &str) -> Result<&mut Self>
any(column).
PHP: anyValue().
Sourcepub fn any_last_value(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn any_last_value(&mut self, column: &str, alias: &str) -> Result<&mut Self>
anyLast(column).
PHP: anyLastValue().
Sourcepub fn group_uniq_array(
&mut self,
column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn group_uniq_array( &mut self, column: &str, alias: &str, ) -> Result<&mut Self>
groupUniqArray(column).
PHP: groupUniqArray().
Sourcepub fn group_array_moving_avg(
&mut self,
column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn group_array_moving_avg( &mut self, column: &str, alias: &str, ) -> Result<&mut Self>
groupArrayMovingAvg(column).
PHP: groupArrayMovingAvg().
Sourcepub fn group_array_moving_sum(
&mut self,
column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn group_array_moving_sum( &mut self, column: &str, alias: &str, ) -> Result<&mut Self>
groupArrayMovingSum(column).
PHP: groupArrayMovingSum().
Sourcepub fn array_join(
&mut self,
column: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn array_join( &mut self, column: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
ARRAY JOIN column [AS alias].
PHP: arrayJoin().
Sourcepub fn left_array_join(
&mut self,
column: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn left_array_join( &mut self, column: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
LEFT ARRAY JOIN column [AS alias].
PHP: leftArrayJoin().
Sourcepub fn asof_join<L: AsRef<str>, R: AsRef<str>>(
&mut self,
table: &str,
equi_pairs: impl IntoIterator<Item = (L, R)>,
left_inequality: &str,
operator: AsofOperator,
right_inequality: &str,
alias: &str,
) -> Result<&mut Self>
pub fn asof_join<L: AsRef<str>, R: AsRef<str>>( &mut self, table: &str, equi_pairs: impl IntoIterator<Item = (L, R)>, left_inequality: &str, operator: AsofOperator, right_inequality: &str, alias: &str, ) -> Result<&mut Self>
ASOF JOIN table [AS alias] ON l = r AND ... AND left operator right.
PHP: asofJoin().
Sourcepub fn asof_left_join<L: AsRef<str>, R: AsRef<str>>(
&mut self,
table: &str,
equi_pairs: impl IntoIterator<Item = (L, R)>,
left_inequality: &str,
operator: AsofOperator,
right_inequality: &str,
alias: &str,
) -> Result<&mut Self>
pub fn asof_left_join<L: AsRef<str>, R: AsRef<str>>( &mut self, table: &str, equi_pairs: impl IntoIterator<Item = (L, R)>, left_inequality: &str, operator: AsofOperator, right_inequality: &str, alias: &str, ) -> Result<&mut Self>
ASOF LEFT JOIN ....
PHP: asofLeftJoin().
Source§impl<D: Dialect> Builder<D>
impl<D: Dialect> Builder<D>
Sourcepub fn class(&self) -> &str
pub fn class(&self) -> &str
The PHP class messages name: the dialect’s, or the subclass of it given to
Builder::set_class.
PHP: static::class.
Sourcepub fn set_class(&mut self, class: impl Into<String>) -> &mut Self
pub fn set_class(&mut self, class: impl Into<String>) -> &mut Self
Names the PHP class of the builder, when it is a subclass of the dialect’s.
Sourcepub fn base_binding_values(&self) -> Vec<Value>
pub fn base_binding_values(&self) -> Vec<Value>
The values bound so far.
PHP: parent::getBindingValues().
Source§impl<D: Locking> Builder<D>
impl<D: Locking> Builder<D>
Sourcepub fn for_update(&mut self) -> &mut Self
pub fn for_update(&mut self) -> &mut Self
FOR UPDATE.
PHP: forUpdate().
FOR SHARE.
PHP: forShare().
Sourcepub fn for_update_skip_locked(&mut self) -> &mut Self
pub fn for_update_skip_locked(&mut self) -> &mut Self
FOR UPDATE SKIP LOCKED.
PHP: forUpdateSkipLocked().
Sourcepub fn for_update_no_wait(&mut self) -> &mut Self
pub fn for_update_no_wait(&mut self) -> &mut Self
FOR UPDATE NOWAIT.
PHP: forUpdateNoWait().
FOR SHARE SKIP LOCKED.
PHP: forShareSkipLocked().
FOR SHARE NOWAIT.
PHP: forShareNoWait().
Source§impl<D: Transactions> Builder<D>
impl<D: Transactions> Builder<D>
Sourcepub fn release_savepoint(&mut self, name: &str) -> Result<Statement>
pub fn release_savepoint(&mut self, name: &str) -> Result<Statement>
RELEASE SAVEPOINT name.
PHP: releaseSavepoint().
Sourcepub fn rollback_to_savepoint(&mut self, name: &str) -> Result<Statement>
pub fn rollback_to_savepoint(&mut self, name: &str) -> Result<Statement>
ROLLBACK TO SAVEPOINT name.
PHP: rollbackToSavepoint().
Source§impl<D: StatisticalAggregates> Builder<D>
impl<D: StatisticalAggregates> Builder<D>
Sourcepub fn stddev(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn stddev( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
STDDEV.
PHP: stddev().
Sourcepub fn stddev_pop(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn stddev_pop( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
STDDEV_POP.
PHP: stddevPop().
Sourcepub fn stddev_samp(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn stddev_samp( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
STDDEV_SAMP.
PHP: stddevSamp().
Sourcepub fn variance(
&mut self,
attribute: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn variance( &mut self, attribute: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
VARIANCE.
PHP: variance().
Source§impl<D: BitwiseAggregates> Builder<D>
impl<D: BitwiseAggregates> Builder<D>
Source§impl<D: RawSql> Builder<D>
impl<D: RawSql> Builder<D>
Sourcepub fn select_cast(
&mut self,
column: &str,
cast_type: &str,
alias: &str,
) -> Result<&mut Self>
pub fn select_cast( &mut self, column: &str, cast_type: &str, alias: &str, ) -> Result<&mut Self>
CAST(column AS type) [AS alias]; the type must be a type name
(words, with an optional argument list).
PHP: selectCast().
Sourcepub fn order_by_raw(
&mut self,
expression: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn order_by_raw( &mut self, expression: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
A raw ORDER BY expression.
PHP: orderByRaw().
Sourcepub fn group_by_raw(
&mut self,
expression: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn group_by_raw( &mut self, expression: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
A raw GROUP BY expression.
PHP: groupByRaw().
Sourcepub fn having_raw(
&mut self,
expression: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn having_raw( &mut self, expression: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
A raw HAVING condition.
PHP: havingRaw().
Sourcepub fn where_raw(
&mut self,
expression: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn where_raw( &mut self, expression: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
A raw WHERE condition.
PHP: whereRaw().
Sourcepub fn where_column(
&mut self,
left: &str,
operator: &str,
right: &str,
) -> Result<&mut Self>
pub fn where_column( &mut self, left: &str, operator: &str, right: &str, ) -> Result<&mut Self>
left operator right, both columns.
PHP: whereColumn().
Sourcepub fn select_case(&mut self, case: CaseExpression) -> &mut Self
pub fn select_case(&mut self, case: CaseExpression) -> &mut Self
A CASE expression in the select list.
PHP: selectCase().
Sourcepub fn set_case(
&mut self,
column: impl Into<String>,
case: CaseExpression,
) -> &mut Self
pub fn set_case( &mut self, column: impl Into<String>, case: CaseExpression, ) -> &mut Self
column = CASE ... in an update.
PHP: setCase().
Sourcepub fn set_raw(
&mut self,
column: impl Into<String>,
expression: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn set_raw( &mut self, column: impl Into<String>, expression: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
column = expression in an update.
PHP: setRaw().
Sourcepub fn conflict_set_raw(
&mut self,
column: impl Into<String>,
expression: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn conflict_set_raw( &mut self, column: impl Into<String>, expression: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
column = expression in an upsert’s conflict update.
PHP: conflictSetRaw().
Sourcepub fn insert_column_expression(
&mut self,
column: impl Into<String>,
expression: impl Into<String>,
extra_bindings: impl IntoValues,
) -> &mut Self
pub fn insert_column_expression( &mut self, column: impl Into<String>, expression: impl Into<String>, extra_bindings: impl IntoValues, ) -> &mut Self
The SQL inserted for column instead of ? (ST_GeomFromText(?)),
with extra bindings after the value.
PHP: insertColumnExpression().
Source§impl<D: CrossJoins> Builder<D>
impl<D: CrossJoins> Builder<D>
Source§impl<D: FullOuterJoins> Builder<D>
impl<D: FullOuterJoins> Builder<D>
Source§impl<D: LateralJoins> Builder<D>
impl<D: LateralJoins> Builder<D>
Sourcepub fn join_lateral(
&mut self,
subquery: Box<dyn AnyBuilder>,
alias: impl Into<String>,
join_type: JoinType,
) -> &mut Self
pub fn join_lateral( &mut self, subquery: Box<dyn AnyBuilder>, alias: impl Into<String>, join_type: JoinType, ) -> &mut Self
[LEFT] JOIN LATERAL (subquery) AS alias ON true.
PHP: joinLateral().
Sourcepub fn left_join_lateral(
&mut self,
subquery: Box<dyn AnyBuilder>,
alias: impl Into<String>,
) -> &mut Self
pub fn left_join_lateral( &mut self, subquery: Box<dyn AnyBuilder>, alias: impl Into<String>, ) -> &mut Self
LEFT JOIN LATERAL.
PHP: leftJoinLateral().
Source§impl<D: Rollup> Builder<D>
impl<D: Rollup> Builder<D>
Sourcepub fn with_rollup(&mut self) -> &mut Self
pub fn with_rollup(&mut self) -> &mut Self
WITH ROLLUP / ROLLUP(...).
PHP: withRollup().
Source§impl<D: Totals> Builder<D>
impl<D: Totals> Builder<D>
Sourcepub fn with_totals(&mut self) -> &mut Self
pub fn with_totals(&mut self) -> &mut Self
WITH TOTALS.
PHP: withTotals().
Source§impl<D: ConditionalAggregates> Builder<D>
impl<D: ConditionalAggregates> Builder<D>
Sourcepub fn count_when(
&mut self,
condition: &str,
alias: &str,
bindings: impl IntoValues,
) -> Result<&mut Self>
pub fn count_when( &mut self, condition: &str, alias: &str, bindings: impl IntoValues, ) -> Result<&mut Self>
COUNT(CASE WHEN condition THEN 1 END) [AS alias].
PHP: countWhen().
Sourcepub fn sum_when(
&mut self,
column: &str,
condition: &str,
alias: &str,
bindings: impl IntoValues,
) -> Result<&mut Self>
pub fn sum_when( &mut self, column: &str, condition: &str, alias: &str, bindings: impl IntoValues, ) -> Result<&mut Self>
SUM(CASE WHEN condition THEN column END).
PHP: sumWhen().
Sourcepub fn avg_when(
&mut self,
column: &str,
condition: &str,
alias: &str,
bindings: impl IntoValues,
) -> Result<&mut Self>
pub fn avg_when( &mut self, column: &str, condition: &str, alias: &str, bindings: impl IntoValues, ) -> Result<&mut Self>
AVG(CASE WHEN ...).
PHP: avgWhen().
Source§impl<D: StringAggregates> Builder<D>
impl<D: StringAggregates> Builder<D>
Sourcepub fn group_concat(
&mut self,
column: &str,
separator: &str,
alias: &str,
order_by: Option<&[String]>,
) -> Result<&mut Self>
pub fn group_concat( &mut self, column: &str, separator: &str, alias: &str, order_by: Option<&[String]>, ) -> Result<&mut Self>
The values of column concatenated with separator, optionally
ordered (-column descending).
PHP: groupConcat().
Sourcepub fn json_array_agg(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn json_array_agg(&mut self, column: &str, alias: &str) -> Result<&mut Self>
A JSON array of column’s values.
PHP: jsonArrayAgg().
Source§impl<D: Json> Builder<D>
impl<D: Json> Builder<D>
Sourcepub fn filter_json_contains(
&mut self,
attribute: impl Into<String>,
value: impl IntoValue,
) -> &mut Self
pub fn filter_json_contains( &mut self, attribute: impl Into<String>, value: impl IntoValue, ) -> &mut Self
The JSON column contains value.
PHP: filterJsonContains().
Sourcepub fn filter_json_not_contains(
&mut self,
attribute: impl Into<String>,
value: impl IntoValue,
) -> &mut Self
pub fn filter_json_not_contains( &mut self, attribute: impl Into<String>, value: impl IntoValue, ) -> &mut Self
The JSON column does not contain value.
PHP: filterJsonNotContains().
Sourcepub fn filter_json_overlaps(
&mut self,
attribute: impl Into<String>,
values: impl IntoValues,
) -> &mut Self
pub fn filter_json_overlaps( &mut self, attribute: impl Into<String>, values: impl IntoValues, ) -> &mut Self
The JSON array column shares an element with values.
PHP: filterJsonOverlaps().
Sourcepub fn filter_json_path(
&mut self,
attribute: impl Into<String>,
path: &str,
operator: &str,
value: impl IntoValue,
) -> &mut Self
pub fn filter_json_path( &mut self, attribute: impl Into<String>, path: &str, operator: &str, value: impl IntoValue, ) -> &mut Self
The value at path compares to value.
PHP: filterJsonPath().
Sourcepub fn set_json_append(
&mut self,
column: &str,
values: impl IntoValues,
) -> Result<&mut Self>
pub fn set_json_append( &mut self, column: &str, values: impl IntoValues, ) -> Result<&mut Self>
Appends values to the JSON array column (in an update).
PHP: setJsonAppend().
Sourcepub fn set_json_prepend(
&mut self,
column: &str,
values: impl IntoValues,
) -> Result<&mut Self>
pub fn set_json_prepend( &mut self, column: &str, values: impl IntoValues, ) -> Result<&mut Self>
Prepends values.
PHP: setJsonPrepend().
Sourcepub fn set_json_insert(
&mut self,
column: &str,
index: i64,
value: impl IntoValue,
) -> Result<&mut Self>
pub fn set_json_insert( &mut self, column: &str, index: i64, value: impl IntoValue, ) -> Result<&mut Self>
Inserts value at index.
PHP: setJsonInsert().
Sourcepub fn set_json_remove(
&mut self,
column: &str,
value: impl IntoValue,
) -> Result<&mut Self>
pub fn set_json_remove( &mut self, column: &str, value: impl IntoValue, ) -> Result<&mut Self>
Removes value.
PHP: setJsonRemove().
Sourcepub fn set_json_intersect(
&mut self,
column: &str,
values: impl IntoValues,
) -> Result<&mut Self>
pub fn set_json_intersect( &mut self, column: &str, values: impl IntoValues, ) -> Result<&mut Self>
Keeps the elements also in values.
PHP: setJsonIntersect().
Sourcepub fn set_json_diff(
&mut self,
column: &str,
values: impl IntoValues,
) -> Result<&mut Self>
pub fn set_json_diff( &mut self, column: &str, values: impl IntoValues, ) -> Result<&mut Self>
Removes the elements in values.
PHP: setJsonDiff().
Sourcepub fn set_json_unique(&mut self, column: &str) -> Result<&mut Self>
pub fn set_json_unique(&mut self, column: &str) -> Result<&mut Self>
Removes duplicates.
PHP: setJsonUnique().
Source§impl<D: FullTextSearch> Builder<D>
impl<D: FullTextSearch> Builder<D>
Sourcepub fn filter_search(
&mut self,
attribute: &str,
value: &str,
) -> Result<&mut Self>
pub fn filter_search( &mut self, attribute: &str, value: &str, ) -> Result<&mut Self>
Full-text search on attribute.
PHP: filterSearch().
Source§impl<D: NegatedFullTextSearch> Builder<D>
impl<D: NegatedFullTextSearch> Builder<D>
Sourcepub fn filter_not_search(&mut self, attribute: &str, value: &str) -> &mut Self
pub fn filter_not_search(&mut self, attribute: &str, value: &str) -> &mut Self
Rows not matching a full-text search.
PHP: filterNotSearch().
Source§impl<D: UpsertSelect> Builder<D>
impl<D: UpsertSelect> Builder<D>
Sourcepub fn upsert_select(&mut self) -> Result<Statement>
pub fn upsert_select(&mut self) -> Result<Statement>
Compiles the upsert from the select source.
PHP: upsertSelect().
Source§impl<D: InsertOrIgnore> Builder<D>
impl<D: InsertOrIgnore> Builder<D>
Sourcepub fn insert_or_ignore(&mut self) -> Result<Statement>
pub fn insert_or_ignore(&mut self) -> Result<Statement>
Compiles an insert that skips rows that conflict.
PHP: insertOrIgnore().
Source§impl<D: TableSampling> Builder<D>
impl<D: TableSampling> Builder<D>
Sourcepub fn tablesample(&mut self, percent: f64, method: &str) -> Result<&mut Self>
pub fn tablesample(&mut self, percent: f64, method: &str) -> Result<&mut Self>
Samples the table.
PHP: tablesample().
Source§impl<D: Returning> Builder<D>
impl<D: Returning> Builder<D>
Sourcepub fn returning<S: Into<String>>(
&mut self,
columns: impl IntoIterator<Item = S>,
) -> &mut Self
pub fn returning<S: Into<String>>( &mut self, columns: impl IntoIterator<Item = S>, ) -> &mut Self
The columns returned after inserts, updates and deletes (["*"] for all;
empty to stop returning).
PHP: returning().
Source§impl<D: Spatial> Builder<D>
impl<D: Spatial> Builder<D>
Sourcepub fn filter_distance(
&mut self,
attribute: impl Into<String>,
point: &Array,
operator: &str,
distance: f64,
meters: bool,
) -> Result<&mut Self>
pub fn filter_distance( &mut self, attribute: impl Into<String>, point: &Array, operator: &str, distance: f64, meters: bool, ) -> Result<&mut Self>
The distance from point ([x, y]) compares to distance with
operator (<, >, =, !=; anything else is <), in meters when
meters. Fails with Error::Validation
unless point is an [x, y] pair of finite numbers.
PHP: filterDistance().
Sourcepub fn filter_intersects(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_intersects( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
The geometry column intersects geometry.
PHP: filterIntersects().
Sourcepub fn filter_not_intersects(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_not_intersects( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Does not intersect.
PHP: filterNotIntersects().
Sourcepub fn filter_crosses(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_crosses( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Crosses.
PHP: filterCrosses().
Sourcepub fn filter_not_crosses(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_not_crosses( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Does not cross.
PHP: filterNotCrosses().
Sourcepub fn filter_overlaps(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_overlaps( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Overlaps.
PHP: filterOverlaps().
Sourcepub fn filter_not_overlaps(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_not_overlaps( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Does not overlap.
PHP: filterNotOverlaps().
Sourcepub fn filter_touches(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_touches( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Touches.
PHP: filterTouches().
Sourcepub fn filter_not_touches(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_not_touches( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Does not touch.
PHP: filterNotTouches().
Sourcepub fn filter_covers(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_covers( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Covers.
PHP: filterCovers().
Sourcepub fn filter_not_covers(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_not_covers( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Does not cover.
PHP: filterNotCovers().
Sourcepub fn filter_spatial_equals(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_spatial_equals( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Spatially equal.
PHP: filterSpatialEquals().
Sourcepub fn filter_not_spatial_equals(
&mut self,
attribute: impl Into<String>,
geometry: Array,
) -> &mut Self
pub fn filter_not_spatial_equals( &mut self, attribute: impl Into<String>, geometry: Array, ) -> &mut Self
Not spatially equal.
PHP: filterNotSpatialEquals().
Source§impl<D: Dialect> Builder<D>
impl<D: Dialect> Builder<D>
Sourcepub fn set_flavor(&mut self, flavor: Flavor) -> &mut Self
pub fn set_flavor(&mut self, flavor: Flavor) -> &mut Self
Sets the builder’s Flavor.
Sourcepub fn scope(&mut self, scope: Arc<dyn Scope>) -> Result<&mut Self>
pub fn scope(&mut self, scope: Arc<dyn Scope>) -> Result<&mut Self>
Reads collections through scope: from() then takes a collection
id.
Fails once from() has read a collection through a scope.
PHP: Scoping::scope().
Sourcepub fn bound_collection(&self) -> Option<(&str, &str)>
pub fn bound_collection(&self) -> Option<(&str, &str)>
The collection and alias the builder read through its scope.
Sourcepub fn from_table(
&mut self,
table: impl Into<String>,
alias: impl Into<String>,
) -> Result<&mut Self>
pub fn from_table( &mut self, table: impl Into<String>, alias: impl Into<String>, ) -> Result<&mut Self>
Reads the table stored under the name as it is, kept to no tenant.
Fails once from() has read a collection through the scope.
PHP: Scoping::fromTable().
Sourcepub fn compile_filters(&mut self, filters: &[Query]) -> Result<Condition>
pub fn compile_filters(&mut self, filters: &[Query]) -> Result<Condition>
The filters joined by AND, each compiled as build() compiles the
filters of its WHERE, with their bindings in order. The builder’s
bindings are replaced by theirs.
PHP: Builder\Filtering::compileFilters() (CompilesFilters).
Source§impl Builder<MongoDbDialect>
impl Builder<MongoDbDialect>
Sourcepub fn push(&mut self, field: &str, value: impl IntoValue) -> Result<&mut Self>
pub fn push(&mut self, field: &str, value: impl IntoValue) -> Result<&mut Self>
Appends value to the array field ($push).
PHP: MongoDB::push().
Sourcepub fn pull(&mut self, field: &str, value: impl IntoValue) -> Result<&mut Self>
pub fn pull(&mut self, field: &str, value: impl IntoValue) -> Result<&mut Self>
Removes value (or the elements matching a condition) from the array field ($pull).
PHP: MongoDB::pull().
Sourcepub fn add_to_set(
&mut self,
field: &str,
value: impl IntoValue,
) -> Result<&mut Self>
pub fn add_to_set( &mut self, field: &str, value: impl IntoValue, ) -> Result<&mut Self>
Adds value to the array field unless present ($addToSet).
PHP: MongoDB::addToSet().
Sourcepub fn increment(
&mut self,
field: &str,
amount: impl IntoValue,
) -> Result<&mut Self>
pub fn increment( &mut self, field: &str, amount: impl IntoValue, ) -> Result<&mut Self>
Adds amount (an integer or a float) to field ($inc).
PHP: MongoDB::increment().
Sourcepub fn unset_fields<S: AsRef<str>>(
&mut self,
fields: impl IntoIterator<Item = S>,
) -> Result<&mut Self>
pub fn unset_fields<S: AsRef<str>>( &mut self, fields: impl IntoIterator<Item = S>, ) -> Result<&mut Self>
Removes the fields from the documents ($unset).
PHP: MongoDB::unsetFields().
Sourcepub fn hint(&mut self, hint: impl Into<IndexHint>) -> &mut Self
pub fn hint(&mut self, hint: impl Into<IndexHint>) -> &mut Self
The index the query uses: a name or a key pattern.
PHP: MongoDB::hint().
Sourcepub fn rename(&mut self, old_field: &str, new_field: &str) -> Result<&mut Self>
pub fn rename(&mut self, old_field: &str, new_field: &str) -> Result<&mut Self>
Renames old_field to new_field ($rename).
PHP: rename() (Feature\MongoDB\FieldUpdates).
Sourcepub fn multiply(
&mut self,
field: &str,
factor: impl IntoValue,
) -> Result<&mut Self>
pub fn multiply( &mut self, field: &str, factor: impl IntoValue, ) -> Result<&mut Self>
Multiplies field by factor ($mul).
PHP: multiply() (Feature\MongoDB\FieldUpdates).
Sourcepub fn pop_first(&mut self, field: &str) -> Result<&mut Self>
pub fn pop_first(&mut self, field: &str) -> Result<&mut Self>
Removes the first element of the array field ($pop: -1).
PHP: popFirst() (Feature\MongoDB\FieldUpdates).
Sourcepub fn pop_last(&mut self, field: &str) -> Result<&mut Self>
pub fn pop_last(&mut self, field: &str) -> Result<&mut Self>
Removes the last element of the array field ($pop: 1).
PHP: popLast() (Feature\MongoDB\FieldUpdates).
Sourcepub fn pull_all(
&mut self,
field: &str,
values: impl IntoValues,
) -> Result<&mut Self>
pub fn pull_all( &mut self, field: &str, values: impl IntoValues, ) -> Result<&mut Self>
Removes every occurrence of values from the array field ($pullAll).
PHP: pullAll() (Feature\MongoDB\FieldUpdates).
Sourcepub fn update_min(
&mut self,
field: &str,
value: impl IntoValue,
) -> Result<&mut Self>
pub fn update_min( &mut self, field: &str, value: impl IntoValue, ) -> Result<&mut Self>
Sets field to value when value is smaller ($min).
PHP: updateMin() (Feature\MongoDB\FieldUpdates).
Sourcepub fn update_max(
&mut self,
field: &str,
value: impl IntoValue,
) -> Result<&mut Self>
pub fn update_max( &mut self, field: &str, value: impl IntoValue, ) -> Result<&mut Self>
Sets field to value when value is larger ($max).
PHP: updateMax() (Feature\MongoDB\FieldUpdates).
Sourcepub fn current_date(
&mut self,
field: &str,
date_type: &str,
) -> Result<&mut Self>
pub fn current_date( &mut self, field: &str, date_type: &str, ) -> Result<&mut Self>
Sets field to the current date (type is date or timestamp) ($currentDate).
PHP: currentDate() (Feature\MongoDB\FieldUpdates).
Sourcepub fn push_each(
&mut self,
field: &str,
values: impl IntoValues,
position: Option<i64>,
slice: Option<i64>,
sort: Option<Array>,
) -> Result<&mut Self>
pub fn push_each( &mut self, field: &str, values: impl IntoValues, position: Option<i64>, slice: Option<i64>, sort: Option<Array>, ) -> Result<&mut Self>
Appends each of values to the array field, at position, keeping
slice elements, sorted by sort ($push with $each).
PHP: pushEach() (Feature\MongoDB\ArrayPushModifiers).
use utopia_query::Query;
use utopia_query::builder::MongoDb;
let statement = MongoDb::new()
.from("users", "")
.filter([Query::equal("_id", ["u1"])])
.push_each("scores", [90, 85], None, Some(-5), None)?
.increment("visits", 1)?
.update()?;
assert_eq!(
statement.query,
r#"{"collection":"users","operation":"updateMany","filter":{"_id":"?"},"update":{"$push":{"scores":{"$each":["?","?"],"$slice":-5}},"$inc":{"visits":1}}}"#
);
assert_eq!(statement.bindings.len(), 3);use Utopia\Query\Builder\MongoDB;
use Utopia\Query\Query;
$statement = (new MongoDB())
->from('users')
->filter([Query::equal('_id', ['u1'])])
->pushEach('scores', [90, 85], slice: -5)
->increment('visits', 1)
->update();
echo $statement->query, "\n";
// {"collection":"users","operation":"updateMany","filter":{"_id":"?"},"update":{"$push":{"scores":{"$each":["?","?"],"$slice":-5}},"$inc":{"visits":1}}}Sourcepub fn array_filter(&mut self, _identifier: &str, condition: Array) -> &mut Self
pub fn array_filter(&mut self, _identifier: &str, condition: Array) -> &mut Self
Adds an arrayFilters condition for a filtered positional update
(field.$[identifier]); the identifier is informational and must be
the root of the condition’s paths.
PHP: arrayFilter() (Feature\MongoDB\ConditionalArrayUpdates).
Sourcepub fn bucket(
&mut self,
group_by: &str,
boundaries: impl IntoValues,
default_bucket: Option<&str>,
output: Array,
) -> &mut Self
pub fn bucket( &mut self, group_by: &str, boundaries: impl IntoValues, default_bucket: Option<&str>, output: Array, ) -> &mut Self
A $bucket stage grouping by group_by between boundaries.
PHP: bucket() (Feature\MongoDB\PipelineStages).
Sourcepub fn bucket_auto(
&mut self,
group_by: &str,
buckets: i64,
output: Array,
) -> &mut Self
pub fn bucket_auto( &mut self, group_by: &str, buckets: i64, output: Array, ) -> &mut Self
A $bucketAuto stage of buckets buckets over group_by.
PHP: bucketAuto() (Feature\MongoDB\PipelineStages).
Sourcepub fn facet<'a, K: AsRef<str>>(
&mut self,
facets: impl IntoIterator<Item = (K, &'a mut dyn AnyBuilder)>,
) -> Result<&mut Self>
pub fn facet<'a, K: AsRef<str>>( &mut self, facets: impl IntoIterator<Item = (K, &'a mut dyn AnyBuilder)>, ) -> Result<&mut Self>
A $facet stage: each named builder (built now) becomes a sub-pipeline.
PHP: facet() (Feature\MongoDB\PipelineStages).
Sourcepub fn graph_lookup(
&mut self,
from: &str,
start_with: &str,
connect_from_field: &str,
connect_to_field: &str,
as_field: &str,
max_depth: Option<i64>,
depth_field: Option<&str>,
) -> &mut Self
pub fn graph_lookup( &mut self, from: &str, start_with: &str, connect_from_field: &str, connect_to_field: &str, as_field: &str, max_depth: Option<i64>, depth_field: Option<&str>, ) -> &mut Self
A $graphLookup stage: a recursive lookup in from.
PHP: graphLookup() (Feature\MongoDB\PipelineStages).
Sourcepub fn merge_into_collection(
&mut self,
collection: &str,
on: Option<Array>,
when_matched: Option<Array>,
when_not_matched: Option<Array>,
) -> &mut Self
pub fn merge_into_collection( &mut self, collection: &str, on: Option<Array>, when_matched: Option<Array>, when_not_matched: Option<Array>, ) -> &mut Self
A terminal $merge stage into collection.
PHP: mergeIntoCollection() (Feature\MongoDB\PipelineStages).
Sourcepub fn output_to_collection(
&mut self,
collection: &str,
database: Option<&str>,
) -> &mut Self
pub fn output_to_collection( &mut self, collection: &str, database: Option<&str>, ) -> &mut Self
A terminal $out stage into collection (of database).
PHP: outputToCollection() (Feature\MongoDB\PipelineStages).
Sourcepub fn replace_root(&mut self, new_root_expression: &str) -> &mut Self
pub fn replace_root(&mut self, new_root_expression: &str) -> &mut Self
A $replaceRoot stage with new_root_expression as the new root.
PHP: replaceRoot() (Feature\MongoDB\PipelineStages).
Sourcepub fn search(&mut self, definition: Array, index: Option<&str>) -> &mut Self
pub fn search(&mut self, definition: Array, index: Option<&str>) -> &mut Self
An Atlas $search stage (first in the pipeline), on index if given.
PHP: search() (Feature\MongoDB\AtlasSearch).
Sourcepub fn search_meta(
&mut self,
definition: Array,
index: Option<&str>,
) -> &mut Self
pub fn search_meta( &mut self, definition: Array, index: Option<&str>, ) -> &mut Self
An Atlas $searchMeta stage: the pipeline returns search metadata only.
PHP: searchMeta() (Feature\MongoDB\AtlasSearch).
Sourcepub fn vector_search(
&mut self,
path: &str,
query_vector: impl IntoValues,
num_candidates: i64,
limit: i64,
index: Option<&str>,
filter: Option<Array>,
) -> &mut Self
pub fn vector_search( &mut self, path: &str, query_vector: impl IntoValues, num_candidates: i64, limit: i64, index: Option<&str>, filter: Option<Array>, ) -> &mut Self
An Atlas $vectorSearch stage over path.
PHP: vectorSearch() (Feature\MongoDB\AtlasSearch).
Source§impl<D: MySqlFamily> Builder<D>
impl<D: MySqlFamily> Builder<D>
Sourcepub fn update_join(
&mut self,
table: impl Into<String>,
left: impl Into<String>,
right: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn update_join( &mut self, table: impl Into<String>, left: impl Into<String>, right: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
UPDATE table JOIN join [AS alias] ON left = right SET ....
PHP: updateJoin().
Sourcepub fn delete_join(
&mut self,
alias: impl Into<String>,
table: impl Into<String>,
left: impl Into<String>,
right: impl Into<String>,
) -> &mut Self
pub fn delete_join( &mut self, alias: impl Into<String>, table: impl Into<String>, left: impl Into<String>, right: impl Into<String>, ) -> &mut Self
DELETE alias FROM table AS alias JOIN join ON left = right.
PHP: deleteJoin().
Sourcepub fn max_execution_time(&mut self, ms: i64) -> Result<&mut Self>
pub fn max_execution_time(&mut self, ms: i64) -> Result<&mut Self>
The MAX_EXECUTION_TIME(ms) hint.
PHP: maxExecutionTime().
Source§impl Builder<PostgreSqlDialect>
impl Builder<PostgreSqlDialect>
Sourcepub fn update_from(
&mut self,
table: impl Into<String>,
alias: impl Into<String>,
) -> &mut Self
pub fn update_from( &mut self, table: impl Into<String>, alias: impl Into<String>, ) -> &mut Self
UPDATE table SET ... FROM other [AS alias]; keeps a condition set by
Builder::update_from_where.
PHP: updateFrom().
Sourcepub fn update_from_where(
&mut self,
condition: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn update_from_where( &mut self, condition: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
The condition joining the UPDATE ... FROM table, with its bindings.
PHP: updateFromWhere().
Sourcepub fn delete_using(
&mut self,
table: impl Into<String>,
condition: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn delete_using( &mut self, table: impl Into<String>, condition: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
DELETE FROM table USING other WHERE condition.
PHP: deleteUsing().
Sourcepub fn distinct_on<S: Into<String>>(
&mut self,
columns: impl IntoIterator<Item = S>,
) -> &mut Self
pub fn distinct_on<S: Into<String>>( &mut self, columns: impl IntoIterator<Item = S>, ) -> &mut Self
SELECT DISTINCT ON (columns).
PHP: distinctOn().
Sourcepub fn for_update_of(&mut self, table: impl Into<String>) -> &mut Self
pub fn for_update_of(&mut self, table: impl Into<String>) -> &mut Self
FOR UPDATE OF table.
PHP: forUpdateOf().
FOR SHARE OF table.
PHP: forShareOf().
Sourcepub fn order_by_vector_distance(
&mut self,
attribute: impl Into<String>,
vector: impl IntoValues,
metric: VectorMetric,
) -> &mut Self
pub fn order_by_vector_distance( &mut self, attribute: impl Into<String>, vector: impl IntoValues, metric: VectorMetric, ) -> &mut Self
Orders by the pgvector distance of attribute to vector (nearest first).
PHP: orderByVectorDistance().
Sourcepub fn select_aggregate_filter(
&mut self,
aggregate: &str,
condition: &str,
alias: &str,
bindings: impl IntoValues,
) -> Result<&mut Self>
pub fn select_aggregate_filter( &mut self, aggregate: &str, condition: &str, alias: &str, bindings: impl IntoValues, ) -> Result<&mut Self>
aggregate FILTER (WHERE condition) [AS alias] in the select list.
PHP: selectAggregateFilter().
Sourcepub fn array_agg(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn array_agg(&mut self, column: &str, alias: &str) -> Result<&mut Self>
ARRAY_AGG(column).
PHP: arrayAgg().
Sourcepub fn bool_and(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn bool_and(&mut self, column: &str, alias: &str) -> Result<&mut Self>
BOOL_AND(column).
PHP: boolAnd().
Sourcepub fn bool_or(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn bool_or(&mut self, column: &str, alias: &str) -> Result<&mut Self>
BOOL_OR(column).
PHP: boolOr().
Sourcepub fn every(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn every(&mut self, column: &str, alias: &str) -> Result<&mut Self>
EVERY(column).
PHP: every().
Sourcepub fn mode(&mut self, column: &str, alias: &str) -> Result<&mut Self>
pub fn mode(&mut self, column: &str, alias: &str) -> Result<&mut Self>
MODE() WITHIN GROUP (ORDER BY column).
PHP: mode().
Sourcepub fn percentile_cont(
&mut self,
fraction: f64,
order_column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn percentile_cont( &mut self, fraction: f64, order_column: &str, alias: &str, ) -> Result<&mut Self>
PERCENTILE_CONT(fraction) WITHIN GROUP (ORDER BY column).
PHP: percentileCont().
Sourcepub fn percentile_disc(
&mut self,
fraction: f64,
order_column: &str,
alias: &str,
) -> Result<&mut Self>
pub fn percentile_disc( &mut self, fraction: f64, order_column: &str, alias: &str, ) -> Result<&mut Self>
PERCENTILE_DISC(fraction) WITHIN GROUP (ORDER BY column).
PHP: percentileDisc().
Sourcepub fn merge_into(&mut self, target: impl Into<String>) -> &mut Self
pub fn merge_into(&mut self, target: impl Into<String>) -> &mut Self
The table a MERGE writes to.
PHP: mergeInto().
Sourcepub fn using(
&mut self,
source: Box<dyn AnyBuilder>,
alias: impl Into<String>,
) -> &mut Self
pub fn using( &mut self, source: Box<dyn AnyBuilder>, alias: impl Into<String>, ) -> &mut Self
The source query of a MERGE, and its alias.
PHP: using().
Sourcepub fn on(
&mut self,
condition: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn on( &mut self, condition: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
The ON condition of a MERGE, with its bindings.
PHP: on().
Sourcepub fn when_matched(
&mut self,
action: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn when_matched( &mut self, action: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
WHEN MATCHED THEN action.
PHP: whenMatched().
Sourcepub fn when_not_matched(
&mut self,
action: impl Into<String>,
bindings: impl IntoValues,
) -> &mut Self
pub fn when_not_matched( &mut self, action: impl Into<String>, bindings: impl IntoValues, ) -> &mut Self
WHEN NOT MATCHED THEN action.
PHP: whenNotMatched().
Sourcepub fn execute_merge(&mut self) -> Result<Statement>
pub fn execute_merge(&mut self) -> Result<Statement>
Compiles the MERGE INTO target USING (source) AS alias ON condition WHEN ....
PHP: executeMerge().
Source§impl<D: Dialect> Builder<D>
impl<D: Dialect> Builder<D>
Sourcepub fn set_overrides(&mut self, overrides: Arc<dyn Overrides>) -> &mut Self
pub fn set_overrides(&mut self, overrides: Arc<dyn Overrides>) -> &mut Self
Asks overrides before each Step.
Sourcepub fn set_overridden(&mut self, steps: u128) -> &mut Self
pub fn set_overridden(&mut self, steps: u128) -> &mut Self
Says which steps the overrides take, a bit for each by its place in Step::ALL:
the others are not asked about.
Sourcepub fn set_owner(&mut self, owner: usize) -> &mut Self
pub fn set_owner(&mut self, owner: usize) -> &mut Self
Says whose builder this is, for the overrides and after_build_owned callbacks to read
back: state kept beside the builder would cross when two builds interleave on a thread.
Sourcepub fn owner(&self) -> usize
pub fn owner(&self) -> usize
The owner Self::set_owner set, or zero: a clone has none.
Sourcepub fn base(&mut self, step: Step, arguments: &[Arg<'_>]) -> Result<Ret>
pub fn base(&mut self, step: Step, arguments: &[Arg<'_>]) -> Result<Ret>
Runs step as the builder itself does, whatever is overridden.
PHP: parent::step(...) in a subclass of the dialect’s builder.
Sourcepub fn validate_table(&mut self) -> Result<()>
pub fn validate_table(&mut self) -> Result<()>
validateTable(): a subclass’s own when it has one.
Sourcepub fn validate_rows(&mut self, operation: &str) -> Result<()>
pub fn validate_rows(&mut self, operation: &str) -> Result<()>
validateRows().
Sourcepub fn validate_and_get_columns(&mut self) -> Result<Vec<ArrayKey>>
pub fn validate_and_get_columns(&mut self) -> Result<Vec<ArrayKey>>
validateAndGetColumns().
Sourcepub fn add_bindings(&mut self, values: impl IntoIterator<Item = Value>)
pub fn add_bindings(&mut self, values: impl IntoIterator<Item = Value>)
addBindings().
Sourcepub fn compile_case(&mut self, case: &CaseExpression) -> Result<String>
pub fn compile_case(&mut self, case: &CaseExpression) -> Result<String>
compileCase().
Sourcepub fn compile_assignments(&mut self) -> Result<Vec<String>>
pub fn compile_assignments(&mut self) -> Result<Vec<String>>
compileAssignments().
Sourcepub fn compile_where_clauses(
&mut self,
parts: &mut Vec<String>,
grouped: Option<&ParsedQuery>,
) -> Result<()>
pub fn compile_where_clauses( &mut self, parts: &mut Vec<String>, grouped: Option<&ParsedQuery>, ) -> Result<()>
compileWhereClauses().
Sourcepub fn compile_order_and_limit(
&mut self,
parts: &mut Vec<String>,
grouped: Option<&ParsedQuery>,
) -> Result<()>
pub fn compile_order_and_limit( &mut self, parts: &mut Vec<String>, grouped: Option<&ParsedQuery>, ) -> Result<()>
compileOrderAndLimit().
Sourcepub fn append_returning(&mut self, result: Statement) -> Result<Statement>
pub fn append_returning(&mut self, result: Statement) -> Result<Statement>
appendReturning().
Sourcepub fn reset_returning(&mut self)
pub fn reset_returning(&mut self)
resetReturning().
Sourcepub fn reset_group_by_modifier(&mut self)
pub fn reset_group_by_modifier(&mut self)
resetGroupByModifier().
Trait Implementations§
Source§impl<D: Dialect> AnyBuilder for Builder<D>
impl<D: Dialect> AnyBuilder for Builder<D>
Source§impl<D: Dialect> Compiler for Builder<D>
impl<D: Dialect> Compiler for Builder<D>
Source§fn compile_filter(&mut self, query: &Query) -> Result<String>
fn compile_filter(&mut self, query: &Query) -> Result<String>
Source§fn compile_order(&mut self, query: &Query) -> Result<String>
fn compile_order(&mut self, query: &Query) -> Result<String>
orderAsc, orderDesc, orderRandom).