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 [`sqlite::select`](crate::select()).
//!
//! Everything a SQLite `SELECT` can carry, and nothing else. There is no
//! `returning` here, no `fetch`, no `for_update`, no `distinct_on`, no
//! `group_by_distinct` and no `_combined` variant of anything — SQLite's grammar
//! has none of them, and a mod for a construct a dialect lacks should not exist.
//!
//! ```
//! use keelson_sqlite as sqlite;
//! use keelson_sqlite::{Chain, arg, quote, select};
//!
//! let q = sqlite::select((
//! select::columns((quote("id"), quote("name"))),
//! select::from(quote("users")),
//! select::where_(quote("age").gte(arg(21i32))),
//! select::order_by(quote("name")).desc().nulls_last(),
//! select::limit(10),
//! select::offset(20),
//! ));
//! ```
//!
//! # `LIMIT` and `OFFSET` are one clause
//!
//! SQLite's production is `LIMIT expr [ ( OFFSET | , ) expr ]`, so [`offset`]
//! without [`limit`] is not a statement. Building one records
//! [`Error::Incomplete`](keelson_core::Error::Incomplete) rather than handing back
//! SQL the database will reject.
//!
//! # `VALUES` is a `SELECT`
//!
//! [`values`] and [`rows`] fill the other alternative of SQLite's `select-core`, so
//! `sqlite::select(select::rows([[1, 2], [3, 4]]))` is the statement
//! `VALUES (1, 2), (3, 4)`. Compounding a `VALUES` core onto a `SELECT` one — and
//! the reverse — is legal and is how a recursive CTE's seed row is usually written.
use ;
use crateSelectQuery;
pub use crate;
/// `SELECT DISTINCT` — drop duplicate result rows.
///
/// `ALL` is the other alternative in the grammar and is the default; writing it adds
/// nothing, so it is not representable.