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
use ;
use crate::;
/// The type-level map, one impl per dialect that HAS a duration. SQLite has none, so
/// [`DurationFilter`] has no comparison there and naming one at that dialect is an unsatisfied
/// bound rather than a column storing something this crate chose. The bound is owed at the
/// comparison's INSTANTIATION and not at the declaration that asks for it: an emitted comparison is
/// generic over the database, so the declaration itself compiles.
///
/// The absence survives the crossing's item bound, and could not have been created by it: a bound
/// on an associated type is discharged by the rows that EXIST, so it can refuse a row and cannot
/// manufacture one. What it adds here is `V: Carrier<Postgres>` — the lowering below, restated —
/// which narrows the dialect's own row without reaching the dialect that has none.
/// A Postgres duration column is an `INTERVAL`, and `V` is [`PgDuration`](crate::PgDuration) — this
/// crate's own carrier, the one an undeclared column reaches, refusing sub-microsecond precision and
/// a microsecond count past the field's `i64` at the CROSSING where this architecture puts every
/// refusal, and carrying the whole signed range.
///
/// Two others remain reachable by DECLARING them, each for something it alone does: [`Duration`]
/// moves the precision refusal to the BIND, and [`PgInterval`](sqlx::postgres::types::PgInterval) is
/// the only route to a MIXED-FIELD interval. All three are microsecond types.
///
/// The negative half of that claim — a stored type from the OTHER dialect has no lowering here:
///
/// ```compile_fail,E0599
/// use ingraph::{
/// At, ComplexComparison, DurationFilter, FieldName, MySqlDuration, RecordAddress, TryFromFilter,
/// comparison::sql::{SqlConjunction, SqlDurationComparison},
/// };
///
/// let c = SqlDurationComparison::<MySqlDuration, sqlx::Postgres>::try_from_filter(
/// DurationFilter::new().with_gte(jiff::SignedDuration::from_secs(1)),
/// )
/// .unwrap();
/// let mut qb = sqlx::QueryBuilder::<sqlx::Postgres>::default();
/// const ROW: RecordAddress = RecordAddress::new(FieldName::new("t"), &[FieldName::new("id")]);
/// let out = SqlConjunction::with_lead(&mut qb, "");
/// let frame = At::new(&ROW).frame(FieldName::new("d"));
/// c.apply(frame.at(), out).unwrap();
/// ```
///
/// Its twin, which must COMPILE — stable rustdoc runs a `compile_fail` block just far enough to see
/// it fail and never checks why:
///
/// ```
/// use ingraph::{
/// At, ComplexComparison, DurationFilter, FieldName, RecordAddress, TryFromFilter,
/// comparison::sql::{SqlConjunction, SqlDurationComparison},
/// };
///
/// let c = SqlDurationComparison::<ingraph::PgDuration, sqlx::Postgres>::try_from_filter(
/// DurationFilter::new().with_gte(jiff::SignedDuration::from_secs(1)),
/// )
/// .unwrap();
/// let mut qb = sqlx::QueryBuilder::<sqlx::Postgres>::default();
/// {
/// const ROW: RecordAddress = RecordAddress::new(FieldName::new("t"), &[FieldName::new("id")]);
/// let out = SqlConjunction::with_lead(&mut qb, "");
/// let frame = At::new(&ROW).frame(FieldName::new("d"));
/// c.apply(frame.at(), out).unwrap();
/// }
/// assert_eq!(qb.sql(), "\"d\" >= $1");
/// ```
///
/// One impl per dialect, because what splits this kind is exactly the `V` above: the SQL is
/// `col >= ?` in every dialect and the storage types the two admit are disjoint.
///
/// [`Duration`]: core::time::Duration