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
//! The affinity and collation rules for a value list and for a compound query.
//!
//! Invariant: **these two functions are SQLite's rules for `x IN (list)` and
//! for the columns of a compound, measured against the pinned 3.53.4 shell**,
//! and they differ from the rules for a comparison between two operands in
//! `collation.rs`: a list takes everything from its left operand, and a
//! compound takes its collation from the leftmost arm that has one.
use ;
use ;
/// Returns the collation of a compound's result column, one expression per arm.
///
/// SQLite's `multiSelectCollSeq`: the leftmost arm whose expression has a
/// collation of its own decides, and an arm whose expression has none (a
/// literal, an arithmetic result) passes the question to the next arm on the
/// right. A plain column always has one, BINARY at least, so it ends the
/// search. Measured against 3.53.4: `SELECT 'A' UNION SELECT 'a' COLLATE
/// NOCASE` is one row, and `SELECT 'A' COLLATE NOCASE UNION SELECT 'a'` is
/// one row too.
///
/// @param exprs - the column's expression in each arm, leftmost first
/// Returns the affinity and collation `operand IN (list)` compares with.
///
/// Measured against 3.53.4: the list items are stored under the LEFT operand's
/// affinity and looked up under the LEFT operand's collation, so an item's own
/// affinity (`1 IN (CAST('1' AS TEXT), 2)` is 0) and column collation
/// (`'A' IN (nocase_column, 'x')` is 0) do not count, and neither does an
/// explicit `COLLATE` on an item. The one exception is a list of a single
/// constant item, which SQLite's parser rewrites to `operand = +item`: then an
/// explicit `COLLATE` on the item counts as it does for `=`, and the unary plus
/// still hides the item's affinity.
///
/// @param operand - the left operand
/// @param list - the bound items between the parentheses