pub struct Function { /* private fields */ }Expand description
A SQLite function call, with the decorations SQLite’s grammar hangs off one.
From https://www.sqlite.org/syntax/aggregate-function-invocation.html and https://www.sqlite.org/syntax/window-function-invocation.html:
name ( [ DISTINCT ] expr [, ...] [ ORDER BY ordering-term [, ...] ] | * )
[ FILTER ( WHERE expr ) ]
name ( expr [, ...] | * ) [ FILTER ( WHERE expr ) ]
OVER ( window-defn | window-name )That is the whole list, and it is shorter than PostgreSQL’s. SQLite has no
WITHIN GROUP (ORDER BY …) — an ordered-set aggregate is not a thing it has —
and no column-definition list on a table-valued function, so neither
appears here. The aggregate ORDER BY inside the argument list needs SQLite
3.44 or later.
use keelson_sqlite::{f, quote, window};
// count(*) OVER (PARTITION BY "user_id")
let e = f("count", "*").over(window::partition_by(quote("user_id")));Implementations§
Source§impl Function
impl Function
Sourcepub fn new(
name: impl Into<Cow<'static, str>>,
args: impl IntoExprList,
) -> Function
pub fn new( name: impl Into<Cow<'static, str>>, args: impl IntoExprList, ) -> Function
A call to name with args.
Sourcepub fn distinct(self) -> Function
pub fn distinct(self) -> Function
DISTINCT, for an aggregate that should see each distinct input once.
Sourcepub fn order_by(self, order: impl IntoExpr) -> Function
pub fn order_by(self, order: impl IntoExpr) -> Function
Add a sort key to the aggregate’s own ORDER BY, inside the argument list:
group_concat("name" ORDER BY "id").
SQLite 3.44 and later.
Sourcepub fn filter(self, condition: impl IntoExpr) -> Function
pub fn filter(self, condition: impl IntoExpr) -> Function
Add a condition to FILTER (WHERE …). Several are AND-joined.
Sourcepub fn over(self, mods: impl Mod<Window>) -> Expr
pub fn over(self, mods: impl Mod<Window>) -> Expr
Attach OVER (…), built from window and
frame mods.
Ends the builder, because OVER is the last thing in the grammar. over(())
gives the legal OVER (), which means the whole partition.
To reference a window declared in the statement’s WINDOW clause use
over_name, not over(window::based_on(..)) — the
parenthesised form is the copying one.
Trait Implementations§
Source§impl Expression for Function
impl Expression for Function
Source§impl HasOrderBy for Function
impl HasOrderBy for Function
Source§fn order_by_mut(&mut self) -> &mut OrderBy
fn order_by_mut(&mut self) -> &mut OrderBy
ORDER BY clause to modify.