1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! Mods for a window definition — what goes inside `OVER (…)` or after
//! `WINDOW name AS`.
//!
//! From <https://www.sqlite.org/syntax/window-defn.html>:
//!
//! ```text
//! ( [ base-window-name ] [ PARTITION BY expr [, ...] ]
//! [ ORDER BY ordering-term [, ...] ] [ frame-spec ] )
//! ```
//!
//! The frame is [`sqlite::frame`](crate::frame), a separate module because the same
//! mods apply to a bare [`Frame`](keelson_core::clause::Frame) as well as to a
//! window.
//!
//! Every part is optional, all of them at once included: `OVER ()` is legal and
//! means the whole partition, which is [`over(())`](crate::Function::over).
//!
//! ```
//! use keelson_sqlite::{f, frame, quote, window};
//!
//! // sum("views") OVER (PARTITION BY "user_id" ORDER BY "id" ROWS UNBOUNDED PRECEDING)
//! let e = f("sum", quote("views")).over((
//! window::partition_by(quote("user_id")),
//! window::order_by(quote("id")),
//! frame::rows(),
//! ));
//! ```
use Cow;
use HasWindow;
use IntoExprList;
use ;
pub use crateorder_by;
/// Extend an existing named window, taking its `PARTITION BY` and — unless this one
/// has its own — its `ORDER BY`.
///
/// SQLite refuses this when the base window has a frame specification, which is why
/// [`Function::over_name`](crate::Function::over_name) exists: that writes
/// `OVER "w"`, a reference, where this builds `OVER ("w" …)`, a copy.
/// `PARTITION BY a, b`. Several calls accumulate.