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
53
54
55
56
57
58
//! The affinity and collation a comparison between two operands uses.
//!
//! Invariant: **a comparison applies the left operand's affinity first and an
//! explicit collation before an implicit one, as `sqlite3BinaryCompareCollSeq`
//! does, and this is the only place those two answers are combined.** The
//! functions moved here from `collation.rs` to keep that file under its
//! recorded size.
use ;
use BoundExpr;
/// Returns the affinity and collation a comparison between two operands uses.
///
/// SQLite's rule, in order: if either side has a column affinity the comparison
/// applies it, with the left side winning. The collation is an explicit one on
/// the left operand, then an explicit one on the right, then the left
/// operand's implicit one, then the right's, and otherwise BINARY. "On an
/// operand" includes anywhere inside it: see [`BoundExpr::explicit_collation`].
///
/// @param left - the comparison's left operand
/// @param right - the comparison's right operand
/// The rules of [`comparison_rules`] for operands whose affinities the caller
/// has already decided.
///
/// **A column of a derived table whose query gave it no affinity has none.** The
/// binder stores that as BLOB, which is also what a declared column with no
/// type has, and the two compare differently: a TEXT column meets the first with
/// TEXT affinity applied to it, and meets the second with nothing converted.
///
/// @param left - the comparison's left operand
/// @param right - the comparison's right operand
/// @param left_affinity - the left operand's affinity as the comparison sees it
/// @param right_affinity - the right operand's affinity as the comparison sees it