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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
//! The per-(storage type × dialect) binding: [`Carrier`], and the sqlx rows this dialect family
//! reaches a column through.
//!
//! # Two layers, not one conflict
//!
//! ```text
//! postgres(type = "BeU64") the DECLARATION: what this field is stored as
//! <BeU64 as Carrier<Postgres>> the FRAMEWORK: how that stored type binds in this dialect
//! ```
//!
//! The framework does not choose the first, and it is not this module's at all: the storage FORMS a
//! declaration spells — [`BeU64`](crate::BeU64) and its neighbours — carry no dialect and are
//! declared in the crate's `storage` module under no backend's feature. What is here is the second
//! layer, which is per-dialect by construction, and an omission in it is an unsatisfied `Carrier`
//! bound naming the field's type and its dialect rather than a query that binds something plausible.
//!
//! [`SqlScalarComparison<V, Db>`](super::SqlScalarComparison) requires that second layer to exist:
//! without a type-level carrier the `Db` parameter has nothing to select.
//!
//! # The table
//!
//! A row exists where the stored bytes are something the dialect can hold; where they are not, the
//! type has NO row and the declaration has to name a storage type that does.
//!
//! | storage type | SQLite | Postgres | MySQL |
//! |---|---|---|---|
//! | `bool`, `i16`, `i32`, `i64`, `f32`, `f64` | native | native | native |
//! | `i8` | native | widened `i16` | native |
//! | `u8` | native | widened `i16` | native |
//! | `u16` | native | widened `i32` | native |
//! | `u32` | native | widened `i64` | native |
//! | `u64` | — | — | native `BIGINT UNSIGNED` |
//! | `u128`, `i128` | — | — | — |
//! | `String` | native `TEXT` | native `TEXT` | native `TEXT` |
//! | [`smol_bytes::Utf8Bytes`] | native `TEXT` | native `TEXT` | native `TEXT` |
//! | `Vec<u8>` | native `BLOB` | native `BYTEA` | native `VARBINARY` |
//! | [`Score`] | native `f32` | native `f32` | native `f32` |
//! | [`Confidence<f64>`] | native `f64` | native `f64` | native `f64` |
//! | [`Duration`] | — | native `INTERVAL` | — |
//! | [`PgInterval`] | — | native `INTERVAL` | — |
//! | [`PgDuration`] | — | native `INTERVAL` | — |
//! | [`MySqlDuration`] | — | — | native `TIME` |
//! | [`BeU64`] | blob | blob | (not needed) |
//! | [`BeU128`], [`BeI128`] | blob | blob | blob |
//! | [`uuid::Uuid`] | native `BLOB` | native `UUID` | native `BINARY(16)` |
//! | `regex::Regex` (behind `regex`) | the PATTERN as native `TEXT` | the same | the same |
//! | [`Count`] | narrowed `i64` | narrowed `i64` | native `BIGINT UNSIGNED` |
//! | [`time::OffsetDateTime`], [`time::PrimitiveDateTime`], [`time::Date`], [`time::Time`] | native | native | native |
//! | [`Temporal<T>`] | as its `T` | as its `T` | as its `T` |
//! | [`TypedId<I, E>`] | as its `I` | as its `I` | as its `I` |
//! | `NonZero*` (ten widths) | as its underlying integer | as its underlying integer | as its underlying integer |
//! | [`Timestamp`] | **two** columns: `i64` + `i32` | the same two | the same two |
//! | `Vec<E>` for `E` in `bool`, `i16`, `i32`, `i64`, `f32`, `f64`, `String`, `Vec<u8>` | — | ONE `E[]` | — |
//!
//! The [`Timestamp`] row is the only one in the table that is not one column, and it is the
//! framework's own instant — see its [`Carrier`] row for the comma between the two binds, and
//! [`ColumnKind`](crate::ColumnKind) for the width the two claims have to agree about.
//!
//! Postgres has no unsigned types and sqlx maps `i8` to `"char"`, which is why four widths widen
//! there and nowhere else. The widened primitive IS the carrier — sqlx already ships all three of
//! its traits — so the widening needs no newtype, only a row that says which integer it becomes.
//!
//! The last row is the COLLECTION boundary a page over a collection column resumes at, and it is
//! Postgres's alone because a native array is: the other two dialects keep every collection in an
//! edge table, so there is no column of the row for a boundary to be a value of. See
//! `pg_array_carriers!` for why it is one bind and never an element expansion.
//!
//! # THE UUID ROW IS NATIVE THREE TIMES OVER, and the three natives are three different columns
//!
//! It is the only row in the table where `native` means a different physical form per dialect rather
//! than one form under three names, and that is the 2026-08-29 ruling: **each backend stores a uuid
//! in its own best form.** Censused off sqlx 0.9's `sqlx-postgres`, `sqlx-mysql` and `sqlx-sqlite`
//! (`src/types/uuid.rs` in each), all three behind that crate's own `uuid` feature, which this
//! crate's `sqlx` feature turns on:
//!
//! | dialect | `Type::type_info` | what `Encode` writes |
//! |---|---|---|
//! | PostgreSQL | `PgTypeInfo::UUID` | the sixteen bytes, no wrapper |
//! | MySQL | `<&[u8]>::type_info()` | the sixteen bytes, length-encoded |
//! | SQLite | `DataType::Blob` | `SqliteArgumentValue::Blob` of the sixteen bytes |
//!
//! **Not one of the three is the canonical text**, which is the fact the row is here to make
//! unmissable — sqlx's MySQL decode says so in its own refusal (*`Uuid` uses binary format for
//! MySQL/MariaDB; for text-formatted UUIDs use `uuid::fmt::Hyphenated`*), and this crate binds
//! `Uuid` rather than either `fmt` wrapper for exactly that reason. The declared words those three
//! forms are spelled with — `uuid`, `binary(16)`, `BLOB` — are `column::stored`'s, where the live
//! catalogue readings and the ORDERING argument that ties all four backends to one byte order are
//! recorded.
//!
//! The row rides `native_carriers!` on all three, `Uuid` being [`Copy`], so no borrowed view is
//! wanted and no blob newtype is in the way: the value binds as itself.
//!
//! # A duration is native on two dialects, absent on the third, and MICROSECONDS on both
//!
//! Measured against sqlx 0.9:
//!
//! | dialect | column | sqlx's bridge | sub-microsecond operand |
//! |---|---|---|---|
//! | Postgres | `INTERVAL` | `Type` + `Encode` + `PgHasArrayType` for [`Duration`]; [`PgInterval`] direct | REFUSED — `PgInterval::try_from` rejects a nanosecond count that is not a multiple of 1000 |
//! | MySQL | `TIME` | `MySqlTime`: `Type`, `Encode`, `Decode` — and `Type` for [`Duration`] with NO `Encode` | **silently truncated** — `MySqlTime::try_from(Duration)` takes `subsec_micros()`, which divides by 1000 |
//! | SQLite | — | none, and SQLite has no temporal type at all | — |
//!
//! Both live dialects stop at MICROSECONDS. The filter's operand — a
//! [`SignedDuration`](jiff::SignedDuration) — carries nanoseconds, so the gap is real, and the two
//! engines disagree about what to do with it: Postgres refuses and MySQL rounds. This crate refuses
//! on both — [`MySqlDuration`] is the carrier a MySQL duration column declares, and its [`TryFrom`]
//! makes the check sqlx's own does not, so a nanosecond operand is a typed error at the CROSSING
//! rather than a value quietly rounded inside a bind. Rounding is invisible in the rendered SQL,
//! which is the property that makes it the worse failure.
//!
//! # …and both are SIGNED columns, which only one of these carriers is
//!
//! `INTERVAL` and `TIME` both hold a negative span, and the filter's operand can now spell one. What
//! stands between them is the CARRIER, and the three differ:
//!
//! | carrier | dialect | negative operand |
//! |---|---|---|
//! | [`PgDuration`] | Postgres | STORED — pure microseconds, sign and all |
//! | [`MySqlDuration`] | MySQL | STORED — the conversion splits magnitude from sign and puts the sign on the `MySqlTime` |
//! | [`Duration`] | Postgres | REFUSED at the crossing — jiff's `TryFrom<SignedDuration> for Duration` has no unsigned value to become |
//! | [`PgInterval`] | Postgres | STORED, and only through a DECLARED converter |
//!
//! The first two rows are this crate's own newtypes and are what an undeclared column reaches on
//! each dialect. They exist for one reason: sqlx 0.9 ships no jiff integration, so neither
//! `MySqlTime` nor `PgInterval` has a conversion from the operand, and `impl TryFrom<SignedDuration>`
//! for either is `E0117` from here — foreign trait, foreign type, and neither sqlx nor jiff depends
//! on the other to write it. A newtype this crate owns is the door through that wall, and it carries
//! the CHECK as well as the conversion.
//!
//! The last two rows are what a DECLARED converter can still reach, and each remains useful for a
//! reason of its own: [`Duration`] refuses a sub-microsecond operand at the BIND rather than at the
//! crossing, and [`PgInterval`] is the only way to write a MIXED-FIELD interval, which a column
//! sharing a schema with something else may need.
//!
//! MySQL's `TIME` also has a CEILING: `±838:59:59`, about 35 days, in each direction. Comfortable
//! for a media duration and not for an accumulated total, and a column that needs more declares
//! `i64` nanoseconds through
//! [`DurationFilter::operand_nanos`](crate::DurationFilter::operand_nanos) — which is checked at
//! both ends, and which is the reason that converter still exists now that neither dialect stores an
//! integer by default.
//!
//! The [`Duration`] and [`PgInterval`] rows are ungated by `jiff`, because both are types a build
//! without it can still name and bind. [`MySqlDuration`]'s row is not: that type exists to convert
//! FROM the filter's operand, so without the feature it has no source type and no reason to be.
//!
//! `u64` has no SQLite or Postgres row because sqlx-sqlite 0.9 ships `Type` and `Decode` for it and
//! no `Encode`, and sqlx-postgres ships none of the three. A `u64` field on either declares
//! [`BeU64`] and crosses into it; on MySQL it needs no declaration at all.
//!
//! # …and [`Count`] HAS a row on all three, which is not that ruling reversed
//!
//! The absence above is about an ARBITRARY 64-bit magnitude — a hash, an offset, an id minted
//! elsewhere — whose top half is ordinary traffic, so narrowing one into an `i64` loses a value
//! nobody agreed to lose. A [`Count`] is not arbitrary: it counts rows that EXIST, so it is bounded
//! by the physical store, and its narrowing crosses no information at all. The type carries that
//! invariant and the row above spends it; a bare `u64` states nothing, so its row stays absent and
//! [`BeU64`] stays the escape a `u64` column declares.
//!
//! The two directions are not symmetric, and the honesty is in the second. The ENCODE saturates at
//! `i64::MAX` over an arm no count reaches. The DECODE refuses a NEGATIVE column by name — see
//! `narrowed_count!` — because nothing this framework writes could have produced one, so it is a
//! corrupt row rather than a wide count.
//!
//! # A CONFIDENCE carries natively at both widths that have a column, and jiff's four INSTANT types
//! carry through [`Temporal`]
//!
//! [`Score`] is `Confidence<f32>`, whose constructor already excludes `NaN`, the infinities and
//! everything outside `[0.0, 1.0]`. Nothing about that invariant is a STORAGE fact, so there is no
//! encoding to own and no newtype to add: the row binds the wrapped float in all three dialects, the
//! crossing from a `ScalarFilter<Score>` is the identity, and a `Score` column therefore needs no
//! declaration. [`Confidence<f64>`] is the same row one width up.
//!
//! **Two widths and not four.** A confidence also measures in `half::f16` and
//! `rust_decimal::Decimal`, and neither has a row here — because neither BARE width has one either.
//! A confidence is a citizen of exactly the faces the width it measures in is a citizen of, so those
//! two reach a schema and stop: they are wire scalars with no `ColumnKind`, which is a fact about
//! what this framework has admitted as a column type rather than about confidences.
//!
//! **sqlx 0.9 ships no `jiff` integration** — its temporal type modules are `chrono` and `time` —
//! so jiff's four instant and civil types reach a column through `time`'s three, which sqlx DOES encode for
//! all three dialects, SQLite included. What this crate supplies is the crossing that reaches them,
//! and it is [`TemporalStorage`](crate::TemporalStorage) rather than a declared converter: the field
//! says `at: Timestamp` and the framework reads the type. [`Temporal<T>`] is what makes that
//! crossing spellable at all — see its own note for the two `E0119`s that make it a coherence result
//! — and it is a storage form rather than a dialect surface, so it lives beside the big-endian
//! carriers and not here.
//!
//! What IS here is the four rows the wrapper needs to reach a sqlx column: its [`Carrier`] row and
//! sqlx's own three. `time`'s three types keep rows of their own beside it, so a column declared as
//! one directly still binds. Those are gated on `time` alone; the wrapper's need `jiff` too, since
//! without it nothing implements [`TemporalStorage`](crate::TemporalStorage) and there is no
//! `Temporal` to write a row for.
//!
//! jiff's FIFTH registered type, `SignedDuration`, is not among them and reaches no `Temporal`: it
//! is an elapsed span rather than an instant, so its storage is the duration section above.
//!
//! [`Duration`]: core::time::Duration
//! [`PgDuration`]: crate::PgDuration
//! [`PgInterval`]: sqlx::postgres::types::PgInterval
//! [`Count`]: crate::Count
//! [`Score`]: crate::Score
//! [`Confidence<f64>`]: crate::Confidence
//! [`Temporal`]: crate::Temporal
//! [`Temporal<T>`]: crate::Temporal
//! [`Timestamp`]: crate::Timestamp
//! [`TypedId<I, E>`]: crate::TypedId
// The temporal storage form this module writes four rows for. It is the crate's rather than this
// family's — see the note above — and the import carries the gate those rows carry. The big-endian
// carriers are imported by the per-dialect modules instead, since that is the only depth their rows
// are written at.
use crateTemporal;
/// One storage type's physical binding in one SQL dialect.
///
/// Public, and deliberately so: this is the surface a downstream scalar or enum joins the
/// comparison vocabulary through. A downstream type with a row here needs nothing else from this
/// crate to be filtered on — the comparison kinds are already generic over it.
///
/// # Why a push rather than an associated bind type
///
/// The method form lets a row render more than a placeholder where a dialect needs one — a cast, a
/// function call — without the trait changing shape. An associated type could carry only the value.
///
/// # The unimplemented note names BOTH exits, because a missing row means one of two things
///
/// The storability audit is where a declaration meets this trait: `impl Record<Db>` names a concrete
/// backend, so every stored column's crossing is checked at the declaration rather than deferred to
/// a call site. What the refusal cannot say for itself is WHICH kind of missing row it is, and the
/// two have opposite answers. A type ONE dialect cannot hold — `u64` on SQLite, which has no
/// unsigned 64-bit column — names the form it is stored as. A type NO dialect can hold is
/// ENGINE-RESIDENT: an [`Embedding`](crate::Embedding) lives in a vector index, and #112's ruling on
/// it is the user's own — *vectors do not belong in record-kind databases* — so the field wears
/// `#[ingraph(skip)]` and the record keeps its rows, its filter, its order and its pages.
/// **A NULLABLE column binds its value where it has one, and `NULL` where it has not.**
///
/// The row a nullable column of ANY type was missing, and the WRITE lane is where its absence
/// showed: an emitted `bind` reaches `<Option<Channel> as Carrier<Db>>::push_bind`, so a record with
/// a nullable column could be declared, filtered, ordered and read back, and not INSERTED. Nothing
/// in the workspace had ever written one, which is how the gap outlived the columns that need it.
///
/// # `NULL` is WRITTEN rather than bound, and the reason is this trait's own shape
///
/// A `None` has no value to hand sqlx, and this trait carries no type a null could be bound AS —
/// [`push_bind`](Carrier::push_bind) is a method on a VALUE, which is what lets a row render a cast
/// or a call rather than a placeholder. Binding `None::<some type>` would pick a type the column may
/// not have: PostgreSQL infers a parameter's type from its bind and refuses a `BOOL` null written
/// into a `TEXT` column. The keyword has no type at all, so the engine takes the column's — and it
/// is a CONSTANT, so nothing a caller supplies reaches the statement.
///
/// # As many `NULL`s as the type is WIDE
///
/// A composite occupies several columns and pushes one placeholder each with its own comma between
/// them — the arrangement [`push_bind`](Carrier::push_bind) documents — so an absent composite has
/// to render the same width, or the `INSERT` list and the `VALUES` list come out different lengths.
/// The count is [`ColumnKind`](crate::ColumnKind)'s, which is the same authority the row's `COLUMNS`
/// is built from, so the two cannot disagree: that trait's own `Option<T>` row already says an
/// optional field is as wide as its value.
///
/// # Nothing else pushes an `Option`
///
/// A filter's operands are never optional — [`Nullable`](crate::Nullable) carries the null test and
/// renders `IS NULL`, and the values inside it are the inner filter's — and a cursor slot holds what
/// the column HOLDS rather than the `Option` holding it, the frame spelling absence itself. So this
/// row is reached from the write lane and from nowhere a keyword would be the wrong shape.
/// `(width, value_width)` of a field of the type whose segments these are — with a SCALAR's empty
/// list answering `(1, 1)`, which is the one column it occupies and the one that holds its value.
const
/// `NULL, NULL, …` — `count` of them, with this family's own separator between.
/// A borrowed operand carries exactly as the owned one does, which is what makes
/// `SqlScalarComparison<&'a V, Db>` a real type rather than an aspiration: the borrowed comparison
/// is the same struct with a different `V`, and it needs no lifetime of its own and no parallel
/// family.
///
/// sqlx supplies the other half — `impl<'q, T, DB: Database> Encode<'q, DB> for &'_ T` and
/// `impl<T: ?Sized + Type<DB>, DB: Database> Type<DB> for &'_ T` — so a reference binds wherever its
/// referent does, with no copy.
/// One row for the typed id, delegating to the id it holds — so the table gains ONE entry rather
/// than one per entity: a [`TypedId`](crate::TypedId) binds wherever its `I` does, in whatever
/// dialect `I` has a row for, and the entity marker reaches no column.
///
/// Generic over `Db` for the reason the wrapper below is: nothing in the delegation is per-dialect.
/// **TWO BINDS OUT, and the comma between them is this row's.**
///
/// The framework's own instant occupies two columns — see
/// [`ColumnKind`](crate::ColumnKind)'s row for the width, which is the claim this one has to agree
/// with. A caller writing a `VALUES` list counts FIELDS and puts a comma between them; the comma
/// inside a field is here, because the count is the type's.
///
/// # Generic over the dialect, where a DOWNSTREAM composite names one
///
/// The derive corpus's `Timebase` writes three rows, one per dialect, and its own note says why: a
/// generic header from outside this crate would overlap the framework's rows for a backend that is
/// not an `sqlx::Database`, and rustc cannot see from out there that none will arrive. From INSIDE
/// there is nothing to overlap — this is the only row for this self type — so the header states the
/// two parts' own requirements and every dialect that carries an `i64` and an `i32` gets the
/// instant for free. All three do.
///
/// The parts bind through their OWN rows rather than through `push_bind` directly, which is what
/// keeps a dialect's decision about an integer the dialect's: Postgres widens four integer widths
/// here, and a composite that reached past those rows would be a second binding path for the same
/// value.
/// One row for the wrapper, delegating to whatever its `T` already has — so the (type × dialect)
/// table gains three entries rather than nine, and a downstream storage form joins by supplying its
/// own [`Carrier`] row and nothing more.
/// sqlx's own [`Type`](sqlx::Type), delegating as the [`Carrier`] row above does — the wrapper
/// declares whatever column its `T` declares, in whatever dialect `T` declares one for.
///
/// # A carrier row is not enough for a COLLECTION
///
/// [`Carrier::push_bind`] is how a scalar operand reaches a query here, and a `Temporal<T>` that had
/// only that could be compared but not held in a Postgres `ARRAY`: the collection lowering binds
/// `&[V]` as ONE parameter, and sqlx routes a slice through the element's own `Type`, `Encode` and
/// [`PgHasArrayType`](sqlx::postgres::PgHasArrayType) rather than through anything this crate
/// declares. Without those three the wrapper had no array type to name, so a `Vec<jiff::Timestamp>`
/// reached an edge table where a `Vec<time::OffsetDateTime>` reached an array column — the same
/// logical column in two physical shapes, chosen by which temporal crate the declaration named.
///
/// # Generic over `Db`, and over `T`
///
/// One impl rather than one per (storage type × dialect): nothing in the delegation is per-dialect,
/// and `#[repr(transparent)]` is not what makes it sound — the inner value is FORWARDED, never
/// reinterpreted, so the impl would be equally correct for a wrapper with any layout.
///
/// # The two bind paths cannot disagree here
///
/// Both end at `T`: the carrier row calls `<T as Carrier<Db>>::push_bind` and these call
/// `<T as Encode<Db>>`, and every storage form this crate ships — `time`'s three — carries through
/// `native_carriers!`, whose body IS `push_bind` and therefore sqlx's `Encode`. A `T` that binds
/// through something else CAN differ: `i8` on Postgres widens to `smallint` here while sqlx types it
/// `"char"`. So these three are not on their own a licence to put any `Temporal<T>` in an array
/// column, and [`PgCollectionStorage`](super::PgCollectionStorage) does not read them as one: the
/// wrapper's strategy is `T`'s DECLARED row, and `i8` declares the edge table.
/// The bytes, delegated whole: all four methods, so a `T` that overrides one is not silently given
/// the trait's default through the wrapper.
///
/// [`produces`](sqlx::Encode::produces) is the one that would matter quietly — it is the per-VALUE
/// type override, consulted ahead of [`Type::type_info`](sqlx::Type::type_info), and a default
/// `None` here would discard a `T`'s answer.
/// The third of the three, and the one with a dialect in its name: sqlx declares it for Postgres
/// alone, so this row is gated where the other two are not.
///
/// It is what makes `&[Temporal<T>]` type as `T[]` — the array OF the column the two impls above
/// name, which is the whole point of delegating rather than inventing one.
/// A [`SignedDuration`](jiff::SignedDuration) stored as MySQL's native `TIME` — the carrier a MySQL
/// duration column declares, and the CHECK sqlx's own conversion does not make.
///
/// # Why a newtype where Postgres needs none
///
/// `MySqlTime` already binds: it has `Type`, `Encode` and `Decode`. What it does not have is a
/// faithful conversion from the filter's operand. It has none from a [`SignedDuration`] at all —
/// sqlx 0.9 ships no jiff integration — and the one it has from a [`Duration`](core::time::Duration)
/// reads `value.subsec_micros()`, whose own comment is *"Simply divides by 1000"*, so a `1500ns`
/// operand becomes `1µs` and the query matches rows the caller did not ask for. Nothing in the
/// rendered SQL shows it.
///
/// Declaring `MySqlTime` directly would put that conversion on the undeclared crossing, which is the
/// path a column with no declared converter takes. This newtype is what makes the checked conversion
/// the only one reachable from here: `MySqlTime` has no [`Carrier`] row of its own, so a duration
/// column on MySQL stores as this type or does not compile.
///
/// # The SIGN, which sqlx's conversion cannot carry and this one must
///
/// `TIME` is a SIGNED type — `±838:59:59` — and `MySqlTime` models that with a
/// [`MySqlTimeSign`](sqlx::mysql::types::MySqlTimeSign) beside a magnitude. sqlx's
/// `TryFrom<Duration>` hard-codes `Positive`, and correctly so: its source type has no other value.
/// A [`SignedDuration`] does, so this conversion splits the operand into magnitude and sign and puts
/// the sign back.
///
/// The magnitude comes from [`SignedDuration::unsigned_abs`], which is total — it is
/// `Duration::new(secs.unsigned_abs(), nanos.unsigned_abs())` and so has no `i64::MIN` panic that a
/// negation would.
///
/// Nothing here reads `MySqlTime::is_negative`. Its body in sqlx 0.9.0 is `self.sign.is_positive()`,
/// which is the inverted answer; `sign()` is the accessor that reports what was set.
///
/// # What it refuses
///
/// [`MySqlDurationError::Nanoseconds`] for sub-microsecond precision `TIME` cannot hold, and
/// [`MySqlDurationError::Ceiling`] past `838:59:59` — about 35 days, which is `TIME`'s whole range
/// in EACH direction. A duration column that must exceed the ceiling stores `i64` nanoseconds
/// instead, through [`DurationFilter::operand_nanos`](crate::DurationFilter::operand_nanos).
///
/// [`SignedDuration`]: jiff::SignedDuration
;
/// The CHECKED conversion, and the whole reason the newtype exists — see its own note for what
/// sqlx's does instead, and for why the sign is applied here rather than left where sqlx puts it.
///
/// # Errors
///
/// [`MySqlDurationError::Nanoseconds`] when `value` carries sub-microsecond precision;
/// [`MySqlDurationError::Ceiling`] when its magnitude exceeds `TIME`'s `838:59:59`.
/// Why a [`SignedDuration`](jiff::SignedDuration) did not become a MySQL `TIME`.
/// A [`SignedDuration`](jiff::SignedDuration) stored as PostgreSQL's native `INTERVAL` — the carrier
/// a Postgres duration column declares, and the door through a wall the orphan rule builds.
///
/// # Why a newtype where sqlx already ships the type
///
/// [`PgInterval`](sqlx::postgres::types::PgInterval) binds: it has `Type`, `Encode`, `Decode` and
/// `PgHasArrayType`. What it does not have, and cannot be given from here, is a conversion from the
/// filter's operand. sqlx 0.9 ships no jiff integration, so `TryFrom<SignedDuration> for PgInterval`
/// would be a foreign trait on a foreign type — `E0117` from this crate, and neither sqlx nor jiff
/// depends on the other to write it. The newtype is a type this crate owns, which is the whole of
/// what the impl needs.
///
/// Before it, an undeclared Postgres duration column reached `core::time::Duration` through jiff's
/// own conversion, and that type is UNSIGNED: a negative operand was refused at the crossing on a
/// dialect whose column holds one perfectly well. This carrier is what closes that gap, and it makes
/// the three backends answer alike — MongoDB stores a signed integer, MySQL a signed `TIME`, and
/// Postgres a signed `INTERVAL`.
///
/// # PURE MICROSECONDS, and the comparison that makes it exact
///
/// The interval is built as `months: 0, days: 0, microseconds: n`. An `INTERVAL` has three
/// independent fields and the same span has many spellings, so the question is whether an operand
/// written in one of them compares correctly against a column written in another.
///
/// It does, and it is measured rather than assumed. PostgreSQL compares two intervals by
/// normalising BOTH through one convention — a month counts as 30 days and a day as 24 hours — so
/// the field split never reaches the comparison. On PostgreSQL 17.10:
///
/// ```text
/// INTERVAL '1 month' = INTERVAL '30 days' = INTERVAL '720 hours' -- all true
/// INTERVAL '1 day' = INTERVAL '24 hours' -- true
/// INTERVAL '719 hours' < INTERVAL '1 month' < INTERVAL '721 hours' -- true
/// ```
///
/// and a pure-microseconds operand of `2592000s` selects the rows stored as `1 mon` AND as
/// `30 days`, with `>=` also reaching `1 mon 1 day`. Negative operands normalise identically.
///
/// So a pure-microseconds operand is exactly as correct as any other spelling, and it is the only
/// one this crate can build honestly: the operand is an elapsed span with no calendar fields in it,
/// and filling `months` or `days` would be inventing a calendar reading the caller never wrote.
///
/// What that inherits — rather than introduces — is the CONVENTION. A column holding `INTERVAL
/// '1 mon'` answers `eq` for an operand of exactly 30 days, because that is what Postgres means by
/// equality here, not because anything was lost on the way in. A schema that needs calendar
/// identity rather than elapsed-span equality wants a different column type, and that is true of
/// every spelling of the operand.
///
/// A column that must hold a mixed-field interval for some other reason still has the escape it
/// always had: [`PgInterval`](sqlx::postgres::types::PgInterval) keeps its own [`Carrier`] row, and
/// a declared converter reaches it.
///
/// # What it refuses
///
/// [`PgDurationError::Nanoseconds`] for sub-microsecond precision `INTERVAL` cannot hold — the same
/// refusal [`MySqlDuration`] makes, because both columns are microsecond types and the filter is a
/// nanosecond one — and [`PgDurationError::Range`] when the microsecond count leaves `i64`, which is
/// the width of the interval's own field.
///
/// [`SignedDuration`]: jiff::SignedDuration
;
/// The CHECKED conversion, and the whole reason the newtype exists.
///
/// # Errors
///
/// [`PgDurationError::Nanoseconds`] when `value` carries sub-microsecond precision;
/// [`PgDurationError::Range`] when its microsecond count does not fit the interval's `i64` field.
/// Why a [`SignedDuration`](jiff::SignedDuration) did not become a PostgreSQL `INTERVAL`.
/// Implement the three sqlx traits for one blob carrier against one database, delegating the type
/// info and the raw bytes to `Vec<u8>` — whichever binary column that database maps it to.
///
/// [`Decode`](sqlx::Decode) is here because a carrier that can only write is a bind helper rather
/// than a carrier: the encoding has ONE authority and an authority names both directions. It is also
/// what makes the encoding testable as a round trip.
///
/// That authority is the storage form's own `to_blob` / `from_blob`, which is what makes this row a
/// BINDING rather than a second encoding. A dialect writing `to_be_bytes` here would agree with the
/// carrier today and be free to stop; the other family's rows call the same two methods, so a
/// `BeU64` column holds the same bytes whichever backend wrote it.
/// **THE CARDINALITY, ON A DIALECT WITH NO UNSIGNED 64-BIT COLUMN** — the three sqlx rows and the
/// [`Carrier`] row a [`Count`](crate::Count) column crosses through on SQLite and PostgreSQL.
///
/// It is `blob_carrier!`'s shape one type over, and it is that shape because the same law applies:
/// the ENCODING has one authority and the authority names both directions.
/// [`Count::to_signed`](crate::Count::to_signed) and
/// [`Count::from_signed`](crate::Count::from_signed) are it — the MongoDB family's row calls the
/// same method, so a `Count` column holds the same value whichever backend wrote it.
///
/// # What the two directions each spend, and why they are not symmetric
///
/// The ENCODE saturates at [`i64::MAX`] over an arm no count reaches: a cardinality counts rows that
/// exist, so it is bounded by the physical store, and that bound is the whole reason this type is
/// carriable where a bare `u64` is not — see [`Count`](crate::Count) for the ruling.
///
/// The DECODE has no such licence. A negative column is a value no write of this framework's could
/// have produced, so it is a corrupt row rather than a wide count, and it is refused BY NAME as
/// [`NegativeCount`](crate::NegativeCount) wrapped in sqlx's own
/// [`ColumnDecode`](sqlx::Error::ColumnDecode) — never clamped to zero, which would answer a
/// question nobody asked and leave no trace anywhere.
/// The rows sqlx already encodes the way this crate stores them: a plain `push_bind`.
/// The rows sqlx encodes as this crate stores them but which are NOT [`Copy`], so the bind names
/// the borrowed view instead of a copy of the value.
///
/// `push_bind<'t, T: Encode<'t, DB>>` takes `'t` as a free lifetime and `QueryBuilder<DB>` carries
/// none, so a `&'a str` whose referent outlives the call binds with no allocation — a clone here
/// would copy every text operand in every query for nothing.
/// A whole COLLECTION as ONE array parameter — the boundary a page over a collection column resumes
/// at.
///
/// # One bind, and never an element expansion
///
/// `push_bind` on a slice is a single `$n` typed `E[]`, whatever the list holds, which is what the
/// collection comparisons above already do (`push_array_op`, `push_mutual_containment`) and what
/// this row joins them in. The alternative — one placeholder per element — would put a ROW's stored
/// value against the dialect's [`BindCeiling`](crate::BindCeiling), so a page over a long list would
/// refuse to render for a reason that has nothing to do with the page. There is no such interaction
/// here, and a bind-count assertion beside the keyset is what keeps it that way.
///
/// The bind names the borrowed view rather than a copy, exactly as `borrowed_carriers!` does and for
/// its reason: cloning a boundary list at every arm of the keyset expansion would copy it three
/// times per term for nothing.
///
/// # It is the CURSOR's row, and it is not a licence to compare a collection as a scalar
///
/// What asks for it is [`SqlKeyset`](super::SqlKeyset), whose boundary values bind through
/// [`Carrier`]. A `ListFilter` still crosses into [`SqlListComparison`](super::SqlListComparison)
/// or an edge kind — the strategy is
/// [`PgCollectionStorage`](super::PgCollectionStorage)'s answer and not this row's, and the two
/// cannot disagree because this table is a strict subset of that one's array rows.
///
/// # The elements, and why exactly these
///
/// The array-stored rows of that same table, intersected with the ones
/// [`CursorValue`](crate::CursorValue) encodes — a boundary needs both halves, since
/// [`SqlOrdering::Value`](crate::query::sql::SqlOrdering::Value) is `Carrier<Db> + CursorValue`. So
/// `Duration`, `PgInterval` and `time`'s three are absent: they ride the array perfectly well and
/// have no cursor codec, which is the same missing row a SCALAR of one already has.
/// The rows whose stored bytes are a WIDER native integer. Only Postgres widens, so the macro is
/// gated with its one user rather than left defined-and-unused in a build without it.
/// This crate's own primitive, at each width that has a column. It binds the WRAPPED value and
/// nothing else: the `[0.0, 1.0]` invariant is a fact about the DOMAIN, maintained by the
/// constructor, and a column has no way to carry it.
///
/// Two widths and not four. `half::f16` and `rust_decimal::Decimal` reach a schema and stop there —
/// neither is a `ColumnKind`, so neither is a width a declaration can name as a column — and a
/// confidence is a citizen of exactly the faces the width it measures in is a citizen of. Binding a
/// `f16` confidence as a `f32` here would have minted a storage decision for a width the framework
/// has not admitted, in the one place nobody would look for it.
/// **A `NonZero*` COLUMN BINDS ITS UNDERLYING INTEGER, THROUGH [`NonZero::get`](core::num::NonZero::get).**
///
/// One generic row per width rather than one per (width × dialect) — the same shape
/// [`Temporal<T>`](Temporal)'s row takes, one paragraph up in this file's history, and
/// [`Confidence<S>`]'s just above. The wrapped integer is what a column HOLDS, so whichever dialect
/// carries that width carries this row for free: `NonZeroU64` binds wherever `u64` does (MySQL
/// alone, by the table above), and `NonZeroU128`/`NonZeroI128` bind nowhere, because `u128`/`i128`
/// do not either. There is nothing to enumerate per dialect — the bound says it once.
///
/// # Why `.get()` and not a second encoding
///
/// The `NonZero` invariant is a fact about the RUST type, maintained by the constructor, exactly as
/// [`Confidence`](crate::Confidence)'s `[0.0, 1.0]` one is — a column has no way to carry it and does
/// not need to: the STORED width is the plain integer (see [`ColumnKind`](crate::ColumnKind)'s row,
/// which answers the scalar default), so the write side hands the underlying value to the width's
/// OWN row rather than inventing a second bind path for the same bytes.
nonzero_carriers!
/// # Nothing silently works, and the compiler is where that is said
///
/// A `u64` column declared as a `u64` on SQLite has no row, so its comparison has no lowering. The
/// omission is a bound naming the type and the dialect, not a query that binds something plausible:
///
/// ```compile_fail,E0599
/// use ingraph::{
/// At, ComplexComparison, FieldName, RecordAddress, ScalarFilter, TryFromFilter,
/// comparison::sql::SqlScalarComparison,
/// };
///
/// let c = SqlScalarComparison::<u64, sqlx::Sqlite>::try_from_filter(
/// ScalarFilter::<u64>::new().with_eq(1u64),
/// )
/// .unwrap();
/// let mut qb = sqlx::QueryBuilder::<sqlx::Sqlite>::default();
/// const ROW: RecordAddress = RecordAddress::new(FieldName::new("t"), &[FieldName::new("id")]);
/// let out = ingraph::comparison::sql::SqlConjunction::with_lead(&mut qb, "");
/// let frame = At::new(&ROW).frame(FieldName::new("n"));
/// c.apply(frame.at(), out).unwrap();
/// ```
///
/// Declaring the storage type the dialect can hold is what makes it compile, and the twin below is
/// what keeps the negative one honest — stable rustdoc runs a `compile_fail` block just far enough
/// to see it fail and never checks why, so the pair shares its imports and its call shape and one
/// half must COMPILE:
///
/// ```
/// use ingraph::{
/// At, BeU64, ComplexComparison, FieldName, RecordAddress, ScalarFilter, TryFromFilter,
/// comparison::sql::SqlScalarComparison,
/// };
///
/// let c = SqlScalarComparison::<BeU64, sqlx::Sqlite>::try_from_filter(
/// ScalarFilter::<u64>::new().with_eq(1u64),
/// )
/// .unwrap();
/// let mut qb = sqlx::QueryBuilder::<sqlx::Sqlite>::default();
/// const ROW: RecordAddress = RecordAddress::new(FieldName::new("t"), &[FieldName::new("id")]);
/// let out = ingraph::comparison::sql::SqlConjunction::with_lead(&mut qb, "");
/// let frame = At::new(&ROW).frame(FieldName::new("n"));
/// c.apply(frame.at(), out).unwrap();
/// assert_eq!(qb.sql(), "\"n\" = ?");
/// ```