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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! The `TsVector` newtype — umbral's Rust binding for Postgres
//! `tsvector`.
//!
//! Postgres tsvector is the lexeme-vector representation used by the
//! full-text search subsystem. It's typically read out of the
//! database (via `to_tsvector(...)`) and queried via the `@@`
//! operator against a `tsquery`. Users rarely construct one
//! by hand — the column is usually populated by a Postgres trigger
//! or a `GENERATED ALWAYS AS (to_tsvector(...)) STORED` clause.
//!
//! sqlx doesn't ship a native binding, so umbral defines a thin
//! newtype around `String` with manual `Type`/`Encode`/`Decode`
//! impls for the Postgres driver. The String holds the on-the-wire
//! text representation, which is what Postgres returns when a
//! `tsvector` is selected without an explicit cast.
use Postgres;
use ;
use ;
/// Postgres `tsvector` column value.
///
/// The inner string carries the lexeme-vector's text representation,
/// the format Postgres uses for `tsvector::text` cast output —
/// space-separated lexemes with optional positions (`'word':1
/// 'phrase':2,3A`).
///
/// Most user code reads this from the database and queries with
/// `FullTextCol::matches(...)`; constructing a TsVector by hand is
/// unusual but supported via the `From<String>` impl.
;
// =========================================================================
// sqlx bindings (Postgres only).
//
// TsVector decodes from the wire as text (the `tsvector::text` cast
// output Postgres returns when the column is selected). Encoding
// writes the same text — Postgres accepts implicit `text -> tsvector`
// cast on INSERT/UPDATE so a bare-text bind works for typical paths.
// Users with strict tsvector input semantics (e.g., must call
// `to_tsvector('english', $1)` to apply a specific config) wrap
// the value in a custom INSERT expression rather than binding through
// the QuerySet.
//
// SQLite gets no impl — `TsVector` only makes sense on Postgres, and
// the `field.backend` system check blocks models with FullText fields
// from booting against SQLite.
// =========================================================================