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
59
//! Array column operator helpers — `contains`, `contained_by`, `overlap`, `len`.
//!
//! # What
//!
//! This module defines the condition variants for Postgres array operators and
//! the `len()` expression. The actual `FieldRef<M, Vec<V>>` methods are in
//! [`crate::query::field`]; this module provides the condition payload types
//! that those methods construct.
//!
//! # SQL operators
//!
//! | Method | SQL | Meaning |
//! |----------------|--------------------------|----------------------------------------|
//! | `contains` | `col @> $1` | column contains all values in the array |
//! | `contained_by` | `col <@ $1` | column values are all in the argument |
//! | `overlap` | `col && $1` | column and argument share at least one element |
//! | `len` | `array_length(col, 1)` | number of elements (1-dimensional arrays only) |
//!
//! Djogi arrays are always 1-dimensional; the `array_length` call is hardcoded
//! to dimension 1. Multi-dimensional arrays are not a supported field type.
//!
//! # No GIN index emission
//!
//! These operators benefit from GIN indexes, but GIN index emission is
//! deferred to Phase 7. The operators work correctly without an index — Postgres
//! falls back to a sequential scan.
use crateFilterValue;
/// Payload for `col @> $1` (array contains).
///
/// The `values` vector is the RHS array to bind as a Postgres array parameter.
/// Every element must be the same Rust type as the column's element type
/// (enforced at construction time by the typed `FieldRef<M, Vec<V>>` API).
/// Payload for `col <@ $1` (array contained by).
/// Payload for `col && $1` (array overlap — at least one element in common).