Skip to main content

ToDatabaseComparison

Trait ToDatabaseComparison 

Source
pub trait ToDatabaseComparison<V, Db: Backend> {
    type Comparison: ComplexComparison<Db>;
}
Expand description

A filter kind mapped to the comparison it crosses into for one storage type and one backend.

Type-level and method-free, for the reason ToGraphqlFilter is: there is nothing here to no-op. The counterpart in the reference implementation is value-level, and every one of its blanket impls is a function whose two branches return the same value, one of them carrying a comment that the line exists to silence a lint. A trait with no method cannot acquire that shape.

§Keyed on the filter, not on the storage type

Keying on the storage type loses the operator set — TextFilter<String> and ScalarFilter<String> would collapse onto one comparison, and the twelve substring operators would have nowhere to go. The filter kind is what carries the question.

§V is a parameter even where the storage form looks fixed

A boolean column’s storage is a DECLARATION, not a law: the same BooleanFilter may be declared to store as a native BOOLEAN, as 0/1, or as 'Y'/'N'. So even the kind with no type parameter of its own crosses into a comparison that has one.

§What the codegen emits, and why it stays a projection

<<FieldTy as ToGraphqlFilter>::Filter as ToDatabaseComparison<StorageTy, Db>>::Comparison

Hard-coding a kind → comparison table in the emitter would close a surface downstream extends: a downstream filter kind arrives with its own row here and needs no emitter change.

§The comparison a crossing names can be LOWERED, and that is an item bound

Comparison: ComplexComparison<Db> is a promise every row keeps, and it is stated here because it cannot be stated anywhere else. A caller holding the projection — <F as ToDatabaseComparison<V, Db>>::Comparison, which is what an expansion writes for every column — has a CONCRETE self type, so rustc resolves it through the impl that defines it and a bound written at the caller demands whatever THAT impl demands of Db. Five spellings were measured and none serves every kind at once: the flat kinds cross under Db: sqlx::Database while ListFilter’s and SetFilter’s cross under CollectionStorage<V>, so no single Db bound is spellable, and a helper trait carrying both capabilities is PROVED rather than assumed through its own blanket and fails on the same kinds.

On the associated type the obligation moves to the party that can discharge it. Each row proves the promise for its own reason — at a concrete dialect, where the dialect’s ComplexComparison impl exists — and a caller states only the crossing.

Db: Backend follows from naming ComplexComparison at all, which is keyed on the BACKEND rather than on a driver’s Database. It is not elaborated: a where F: ToDatabaseComparison<V, Db> at a caller is well-formed only with Db: Backend beside it, which is a bound about the database and not about a column’s crossing, and is one every lowering already carries because ComplexComparison::apply spells Db::Builder.

§The CROSSING is not a second item bound here, and the reason is no longer the edge table

Comparison: TryFromFilter<Self> reads like the other half of the same promise and is not stated. The reason it used to carry is retired and the record should say which. It read that the crossing was REFUTED by the kind with two storage strategies, because a collection’s crossing lands on SqlEdgeComparison wherever a dialect keeps a value list in an edge table and that comparison was constructed WITH its addressing — none of which is in a filter. It no longer is: the addressing arrives at apply through At, and both edge kinds implement TryFromFilter like every other kind.

What remains is the paragraph above, applied to the other trait: a bound spelled at a CALLER resolves through the impl that defines the projection, so it demands whatever that impl demands of Db, and no one spelling serves both the flat kinds and the collection ones. The promise also cannot travel down to CollectionStorage as the lowering one does, because the filter’s DOMAIN type is not a parameter there and no for<D> over types exists to state it with.

So a caller gets the LOWERING from the crossing, and the construction arrives through ToCrossedComparison instead — a refinement whose two METHODS return the projection rather than naming it in a bound, which is the one place the normalisation above does not happen. Whether the MAP itself can carry a second item bound is still open rather than refuted; it is no longer the only way to the crossing, and so no longer worth paying a row for.

§What the wall is really about is the DIALECT, and a caller at a concrete one walks past it

A caller that names the BACKEND rather than carrying it as a parameter normalises the projection and needs no bound at all: the comparison resolves to a kind, that kind’s TryFromFilter row applies, and its inherent try_from_filter_with is callable. ingraph-derive’s INTERFACE expansion is exactly that caller — an interface’s engine face is per database, so its crossing is written per database — and the same code at a generic Db fails with the four errors above, measured. The question that left open — whether a caller which must stay dialect-GENERIC can reach the crossing at all — is now answered yes, and the item bound was not what answered it: see ToCrossedComparison, where the crossing is a method and so is never a bound the wall can be reached through.

Required Associated Types§

Source

type Comparison: ComplexComparison<Db>

The comparison a filter of this kind crosses into, holding V and lowering for Db.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ToDatabaseComparison<Timestamp, Mongo> for TimeRangeFilter

Available on crate feature mongo only.

The range filter crosses into the range comparison for the one backend this family has, and the header naming Mongo concretely is what keeps it from overlapping the SQL row — see MongoScalarComparison’s own note, where the coherence argument is made.

Source§

impl<D, I, V, Db> ToDatabaseComparison<V, Db> for ScalarFilter<D, I>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, V: Carrier<Db> + ColumnKind,

Available on crate feature sqlx only.

Every SQL dialect takes the scalar filter to the scalar comparison; only the storage type and the dialect vary, and both are parameters. The MongoDB family joins beside this over the same trait — measured, not assumed: impl<…, Db: sqlx::Database> here and impl<…> …<Mongo> there do NOT overlap, because Mongo would be local and nothing may implement sqlx::Database for it.

§The rest of the bounds are the LOWERING’s, restated

ToDatabaseComparison::Comparison promises ComplexComparison, so this row has to PROVE it rather than assume it, and what proves it is the bound list the lowering below already carries — including ColumnKind, which is the operand’s WIDTH and is what the lowering reads to know whether it is naming one column or several. Db: sqlx::Database stays at the head of that list for the coherence reason above, which the added bounds do not replace: Backend is a trait this crate declares, so a local Mongo may implement it and the overlap argument would be gone if that were all the header said.

Source§

impl<D, I, V, Db> ToDatabaseComparison<V, Db> for TextFilter<D, I>

Available on crate feature sqlx only.

The lowering promise is stated as the COMPARISON’s own bound, because this kind has no other spelling for it.

ToDatabaseComparison::Comparison promises ComplexComparison, so a row proves it. The three kinds whose lowering is ONE generic impl prove it by restating that impl’s bound list; this kind’s lowering is three CONCRETE impls whose bounds disagree — SQLite asks V: Carrier<Sqlite> and the two LIKE dialects add V: AsRef<str> to build a pattern — so there is no bound list to restate. What is true of all three at once is exactly SqlTextComparison<V, Db>: ComplexComparison<Db>, and at a dialect that resolves to whichever impl the dialect has.

Db: sqlx::Database is kept for the coherence reason SqlScalarComparison’s row records, and Db: Backend because naming ComplexComparison needs it and it is not elaborated from the crossing.

The READING parameter is carried but never read: what a crossing spends is the OPERANDS, and the wire form they arrived under is spent by the time one is built. Generic over it so a declarer’s own text type — whose filter names a marker that crate owns — reaches storage exactly as TextFilter<String> does.

Source§

impl<D, I, V: MongoCarrier + AsRef<str>> ToDatabaseComparison<V, Mongo> for TextFilter<D, I>

Available on crate feature mongo only.

The crossing states the LOWERING’s bounds rather than the carrier’s alone, so a storage type whose text this backend cannot read is refused where it is DECLARED.

Its SQL twin cannot do that. Three concrete impls whose bounds disagree have no bound list to restate, so the SQL row names SqlTextComparison<V, Db>: ComplexComparison<Db> instead. This family has one lowering, so its two bounds are the honest statement and the error a declarer gets names the missing trait.

The READING parameter is carried but never read: what a crossing spends is the OPERANDS, and the wire form they arrived under is spent by the time one is built. Generic over it so a declarer’s own text type — whose filter names a marker that crate owns — reaches storage exactly as TextFilter<String> does.

Source§

impl<D, I, V: MongoCarrier> ToDatabaseComparison<V, Mongo> for ScalarFilter<D, I>

Available on crate feature mongo only.

The scalar filter crosses into the scalar comparison for the one backend this family has, and the header naming Mongo concretely is what keeps it from overlapping the SQL row.

Coherence permits it because Mongo is LOCAL and sqlx::Database is foreign: only this crate could write impl sqlx::Database for Mongo, and it has not, so Db = Mongo cannot unify with a header demanding one. Measured rather than assumed — the SQL row’s own note predicted this and this is the compilation that checks it.

Source§

impl<D, V, Db> ToDatabaseComparison<V, Db> for EnumFilter<D>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, V: Carrier<Db>,

Available on crate feature sqlx only.

The bounds are the LOWERING’s, restated — see SqlBooleanComparison’s row for what the crossing’s item bound asks of a kind whose lowering is one generic impl.

Source§

impl<D, V, Db> ToDatabaseComparison<V, Db> for FlagsFilter<D>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, V: Carrier<Db>,

Available on crate features flags and sqlx only.

The bounds are the LOWERING’s, restated — see SqlEnumComparison’s row.

Source§

impl<D, V, I, Db> ToDatabaseComparison<V, Db> for BytesFilter<D, I>

Available on crate feature sqlx only.

The lowering promise is stated as the COMPARISON’s own bound, for the reason SqlTextComparison’s row gives: this kind lowers through three concrete per-dialect impls, so there is no generic bound list to restate — only the fact that the dialect in hand has one of them.

Source§

impl<D, V, const N: usize, I, Db> ToDatabaseComparison<V, Db> for FixedBytesFilter<D, N, I>

Available on crate feature sqlx only.

The fixed kind’s row, and it lands on the SAME comparison — a storage side reads no width.

Source§

impl<D, V: MongoCarrier, I> ToDatabaseComparison<V, Mongo> for BytesFilter<D, I>

Available on crate feature mongo only.

One backend, so one row — and the header naming Mongo concretely is what keeps it from overlapping the SQL one, for the coherence reason MongoScalarComparison’s row records.

The bound is the LOWERING’s and it is exactly the carrier. Nothing here derives a value from an operand the way a LIKE pattern or a $regex does, so a byte column asks for no AsRef<[u8]> — the one bound MongoTextComparison’s row carries that this does not, and the same place the SQL family’s three bytes impls land.

The WIDTH is not stated here. What decides a refusal is the crossing’s bound rather than the lowering’s, and the crossing is deliberately not an item bound on this map — see ToDatabaseComparison for why that promise cannot travel with the projection.

Source§

impl<D, V: MongoCarrier, const N: usize, I> ToDatabaseComparison<V, Mongo> for FixedBytesFilter<D, N, I>

Available on crate feature mongo only.

The fixed kind’s row, and it lands on the SAME comparison — a storage side reads no width.

Source§

impl<D, V: MongoCarrier> ToDatabaseComparison<V, Mongo> for EnumFilter<D>

Available on crate feature mongo only.

One backend, so one row — and the header is concrete for the coherence reason MongoScalarComparison’s records.

Source§

impl<D, V: MongoCarrier> ToDatabaseComparison<V, Mongo> for FlagsFilter<D>

Available on crate features flags and mongo only.

One backend, so one row — and the header is concrete for the coherence reason MongoScalarComparison’s records.

Source§

impl<D, VF, V, Db: CollectionStorage<V, VF>> ToDatabaseComparison<V, Db> for ListFilter<D, VF>

Available on crate feature sqlx only.

The type-level map, keyed on the dialect’s declared strategy: a ListFilter crosses into whichever comparison the database that answers keeps a SEQUENCE in.

It is the crossing where the choice lands rather than anything below it, because ToDatabaseComparison’s Comparison is already keyed on Db. Nothing about ComplexComparison changes and no other filter kind pays for it.

§The element filter crosses FIRST, and the collection reads its answer

VF is the element’s filter kind, and the comparison the collection holds is whatever THAT filter crosses into over the SAME storage type and the same dialect — because a collection’s members are stored as V, whether in a column, an array or an edge row. So this row projects through VF’s own crossing and hands the result to the storage map, which is what keeps the element’s vocabulary the element’s: a text element brings the substring family and a scalar one does not, with nothing here choosing between them.

Source§

impl<D, VF, V, Db: CollectionStorage<V, VF>> ToDatabaseComparison<V, Db> for QuantifiedFilter<D, VF>

Available on crate feature sqlx only.

The narrow collection reads the SEQUENCE half, and that is a storage fact rather than a choice between two equally good rows.

CollectionStorage’s two answers name a STRATEGY — a native array, or an edge table — and nothing about which operators a filter publishes. A quantified column’s elements are written in the order the writer produced them, so a sequence is what is stored; the filter simply declines to ask about that order. Reading the Set half instead would name the strategy an UNORDERED column takes, and the two differ in the shape of the table on the dialects where they differ at all.

So no third associated type is added, and none is wanted: a row this crate does not ship would have to answer it, and what it would answer is the sequence strategy it already states.

Source§

impl<D, VF, V, Db: CollectionStorage<V, VF>> ToDatabaseComparison<V, Db> for SetFilter<D, VF>

Available on crate feature sqlx only.

The same map for a set, reading the other half of the same row.

Source§

impl<D, VF, V> ToDatabaseComparison<V, Mongo> for ListFilter<D, VF>

Available on crate feature mongo only.

The sequence filter crosses into the sequence comparison, and the ELEMENT filter crosses FIRST.

VF is the member’s filter kind, and the comparison this collection holds is whatever THAT filter crosses into over the SAME storage type — because a collection’s members are stored as V, in the array beside its siblings. So this row projects through VF’s own crossing, which is what keeps the member’s vocabulary the member’s.

The projection sits in the associated type and in the where-clause rather than in this header’s ARGUMENTS, which is what keeps it resolvable: V and Mongo are both concrete here, so an expansion assuming this predicate at a database it has not named yet has nothing to infer. The SQL family reaches the same property by a different route — its projection lives inside a storage row, because there the dialect is the thing not yet named.

It does not overlap the SQL family’s row for the same filter, for the coherence reason MongoScalarComparison’s row records: that one is keyed on Db: CollectionStorage<V, VF>, whose supertrait is the FOREIGN sqlx::Database, and Mongo is local and has no such row.

Source§

impl<D, VF, V> ToDatabaseComparison<V, Mongo> for QuantifiedFilter<D, VF>

Available on crate feature mongo only.

The NARROW collection reads the SEQUENCE comparison, for the reason its SQL twin reads the sequence strategy: a quantified column’s members are written in the order the writer produced them and the filter simply declines to ask about that order. There is one BSON array either way, so what the choice decides here is only which struct holds the two crossed slots.

Source§

impl<D, VF, V> ToDatabaseComparison<V, Mongo> for SetFilter<D, VF>

Available on crate feature mongo only.

The same map for a set.

Source§

impl<Db> ToDatabaseComparison<(String, Confidence<f32>), Db> for DetectedLanguageFilter
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, String: Carrier<Db>, Score: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features derive and sqlx only.

Every SQL dialect takes the detection filter to the detection comparison, and the storage type is the PAIR rather than a parameter.

V is (String, Score) because the two halves hold different types, and one scalar V would name one of them and hide the other — the shape every PAIRED comparison states. The identity’s four columns are all String, which is why one word covers them.

Source§

impl<Db> ToDatabaseComparison<Detection, Db> for DetectionFilter
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>>, SqlTextComparison<Label, Db>: ComplexComparison<Db>, SqlScalarComparison<Score, Db>: ComplexComparison<Db>,

Available on crate feature sqlx only.

THE ROUTING ROW — a Detection column is reached by a DetectionFilter, in every SQL dialect.

The storage type is the DOMAIN TYPE and not the (Label, Score) pair its two columns hold, and the difference is what makes this house DECLARABLE. A record naming a field of this type asks its emitted FromRow for ToDatabaseComparison<Detection, Db> — the type it wrote, not a tuple nothing spells — so a pair-shaped row would leave the declaration with E0277 naming a type it never mentioned. SqlDetectedLanguageComparison routes on the pair, which is consistent with that family having no Assemble row and therefore no declaration that can hold one bare; the geometry house routes on the holder, and this house follows the house that can be declared.

Source§

impl<Db> ToDatabaseComparison<LocalTimestamp, Db> for LocalTimestampFilter
where Db: Database + BindCeiling + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Error = SqlLoweringError, Buffer: Display>, bool: Carrier<Db>, i32: Carrier<Db>, i64: Carrier<Db>, Temporal<PrimitiveDateTime>: Carrier<Db>, Temporal<i32>: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features derive and sqlx and time only.

The comparison, keyed by the CITIZEN — the row a field declared LocalTimestamp resolves through.

Source§

impl<Db> ToDatabaseComparison<MediaTimeRange, Db> for MediaTimeRangeFilter
where Db: Database + BindCeiling + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Error = SqlLoweringError, Buffer: Display>, i32: Carrier<Db>, i64: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features mediatime and sqlx only.

The same comparison, keyed by the CITIZEN — the row a field declared MediaTimeRange resolves through, and the widest of the four: the projection reaches SIX columns by path, two counts, the nested timebase’s pair and two derived positions.

MediaTimestamp’s note above is this one’s argument in full. What is worth stating here is the half-openness, because a whole-value declaration is the first place a reader meets the interval algebra without having written the columns themselves: [start, end) is the family law, the comparison emits < and <= accordingly, and none of that moves when the field is declared at the citizen rather than flattened by hand.

Source§

impl<Db> ToDatabaseComparison<MediaTimestamp, Db> for MediaTimestampFilter
where Db: Database + BindCeiling + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Error = SqlLoweringError, Buffer: Display>, i32: Carrier<Db>, i64: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features mediatime and sqlx only.

The same comparison, keyed by the CITIZEN — the row a field declared MediaTimestamp resolves through, where the row above is the one findit’s hand-flattened at_pts column resolved through.

The comparison already reaches FOUR columns by path — the declared count, the nested timebase’s two, and the derived position — so what a whole-value declaration changes is which map entry the expansion looks up and nothing about the statement it lowers into. That is why this row states the identical projection rather than a second one: a composite field and a hand-flattened field ask the same SQL, and the only thing that ever differed was who wrote the column names.

The two rows cannot overlap — MediaTimestamp is not i64 — so an author reaches whichever one their declaration names.

Source§

impl<Db> ToDatabaseComparison<Rate, Db> for RateFilter
where Db: Database + BindCeiling + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Error = SqlLoweringError, Buffer: Display>, i32: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features mediatime and sqlx only.

The same comparison, keyed by the CITIZEN — the row a field declared Rate resolves through, where the row above is the one a hand-flattened fps_num/fps_den pair resolves through.

It is Timebase’s arrangement word for word, and for its reason: the columns, the crossing and the rendered SQL are identical, so the second key names the same projection and the two rows cannot overlap because Rate is not i32.

Source§

impl<Db> ToDatabaseComparison<String, Db> for LanguageIdFilter
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, String: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features derive and sqlx only.

Every SQL dialect takes the identity filter to the identity comparison, and the storage type is String rather than a parameter: all four columns hold text by construction, so a declaration naming any other column type gets no impl and does not compile.

The Db: sqlx::Database bound is what leaves room beside this for a MongoLanguageIdComparison — nothing may implement sqlx::Database for a future local Mongo marker, so the two impls cannot overlap.

Source§

impl<Db> ToDatabaseComparison<Timebase, Db> for TimebaseFilter
where Db: Database + BindCeiling + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Error = SqlLoweringError, Buffer: Display>, i32: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features mediatime and sqlx only.

The same comparison, keyed by the CITIZEN rather than by the column type its halves land in — the row that lets #[ingraph::record] take a field declared Timebase where an author previously had to hand-flatten it into a num/den pair.

The row above answers for i32, which is what a HAND-FLATTENED declaration names: an author who writes timebase_num: i32 and hangs this filter on it is asking about one column, and the map keyed by that column’s type is what serves them. A field declared at the citizen’s OWN type asks the identical question of the identical columns — ColumnKind::SEGMENTS spans the same two and the lowering descends into them by PATH — so the projection is the SAME comparison, and this row adds a KEY rather than a behaviour. Nothing about the rendered SQL moves.

The two rows cannot overlap, which is what makes holding both sound: V is the map’s first parameter, and Timebase is a local newtype that is not i32. A declaration reaches exactly one of them, decided by the type its author wrote.

Source§

impl<Db> ToDatabaseComparison<Timestamp, Db> for TimeRangeFilter
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, Timestamp: Carrier<Db> + ColumnKind,

Available on crate feature sqlx only.

Every SQL dialect takes the range filter to the range comparison, and the storage type is Timestamp — the ONE type all four columns hold, so one word covers them.

Source§

impl<Db> ToDatabaseComparison<i32, Db> for RateFilter
where Db: Database + BindCeiling + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Error = SqlLoweringError, Buffer: Display>, i32: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features mediatime and sqlx only.

Every SQL dialect takes the rate filter to the rate comparison, and the storage type is i32 rather than a parameter: both halves of a rate are i32 by construction, so a declaration naming any other column type gets no impl and does not compile.

Source§

impl<Db> ToDatabaseComparison<i32, Db> for TimebaseFilter
where Db: Database + BindCeiling + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Error = SqlLoweringError, Buffer: Display>, i32: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features mediatime and sqlx only.

Every SQL dialect takes the timebase filter to the timebase comparison, and the storage type is i32 rather than a parameter: both halves of a timebase are i32 by construction, so a declaration naming any other column type gets no impl and does not compile. One V covers two columns without compromise here, because the two hold the same type.

The Db: sqlx::Database bound is what leaves room beside this for a MongoTimebaseComparison — nothing may implement sqlx::Database for a future local Mongo marker, so the two impls cannot overlap.

§The rest of the bounds are the LOWERING’s, restated

ToDatabaseComparison::Comparison promises ComplexComparison, so this row has to PROVE it rather than assume it — and what proves it is the impl above, whose list this is. Stated as the DIALECT’s capabilities rather than as SqlTimebaseComparison<Db>: ComplexComparison<Db> because this is the row a generated where-struct resolves a projection through: a bound naming a comparison type would make this the one column whose crossing a caller cannot satisfy by knowing which database it has.

Source§

impl<Db> ToDatabaseComparison<i64, Db> for MediaTimeRangeFilter
where Db: Database + BindCeiling + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Error = SqlLoweringError, Buffer: Display>, i32: Carrier<Db>, i64: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features mediatime and sqlx only.

Every SQL dialect takes the range filter to the range comparison, and the storage type is i64 — the derived columns’, which is what a declaration names.

Source§

impl<Db> ToDatabaseComparison<i64, Db> for MediaTimestampFilter
where Db: Database + BindCeiling + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Error = SqlLoweringError, Buffer: Display>, i32: Carrier<Db>, i64: Carrier<Db>, for<'a> &'a str: Encode<'a, Db> + Type<Db>,

Available on crate features mediatime and sqlx only.

Every SQL dialect takes the timestamp filter to the timestamp comparison, and the storage type is i64 — the derived column’s, which is the one a declaration names.

Source§

impl<F, V, Db> ToDatabaseComparison<Option<V>, Db> for Nullable<F>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, F: ToDatabaseComparison<V, Db>, V: ColumnKind,

Available on crate feature sqlx only.

The nullable filter crosses into the nullable comparison over whatever its inner kind crosses into — one impl for every kind, present and future.

§The Option lands HERE and nowhere below it

The storage type this impl is asked for is the COLUMN’s, so a nullable column names Option<V> — and V is what the inner comparison is built over. That is the whole content of the Option<V> in the header, and without it the wrapper passed the column’s storage type straight down: Option<Uuid7> crossed into SqlNullable<SqlScalarComparison<Option<Uuid7>, Db>>, where eq: Some(None) and null: Some(true) are two spellings of is-null. One of them is the operator this wrapper exists to be the only home of; the other is an operand whose None no lowering reads as anything but a bind of SQL NULL, which = never matches.

After it, eq: Some(None) is not a question with a bad answer. The slot is an Option of the OPERAND — presence, which every slot carries — and the operand is now Uuid7, so the inner None has no type to be. The second spelling is UNSPELLABLE rather than unused, which is the same standard Nullable holds the filter side to: a NOT NULL column has no with_null to call.

Nothing overlaps it. Nullable<F> is this crate’s only self type on this trait that is a wrapper — the flat kinds impl for BooleanFilter, ScalarFilter<D>, TextFilter<D>, BytesFilter<D, K>, EnumFilter<D>, ListFilter<D>, SetFilter<D> and DurationFilter, each a distinct type — so narrowing this header from V to Option<V> removes crossings and adds no ambiguity. What it removes is exactly the ones that were wrong: a nullable column whose declared storage type is NOT an Option no longer crosses at all, where before it crossed into a comparison that could not express the column’s own null test as anything but a value.

§A nullable column that OVERRIDES its storage type spells the Option

ingraph-codegen writes a column’s stored type verbatim — the type = "…" override when there is one, the domain type otherwise (PersistColumn::ty). So a nullable column with no override crosses as Option<Uuid7> and lands here, while #[ingraph(optional, sqlite(type = "i64"))] asks for ToDatabaseComparison<i64, Sqlite> and no longer resolves. The spelling that does is type = "Option<i64>", which is also what the column IS: nullable, stored as i64.

That is a refusal replacing a wrong answer rather than a capability lost. The bare override used to resolve, and what it resolved to was the two-spellings shape this impl exists to remove. Nothing in this repository declares the combination today, and rustc names the fix on its own — the trait ToDatabaseComparison<i64, Sqlite> is not implemented for Nullable<ScalarFilter<u64>> but trait ToDatabaseComparison<Option<_>, Sqlite> is implemented for it.

§The two spellings, as the compiler sees them

A nullable column’s operands are the column’s storage type with the Option taken off. Both blocks name a dialect where they used to name (), and both are gated on one: the crossing’s item bound promises the comparison LOWERS, ComplexComparison is keyed on a Backend, and the only backends there are, are dialects. The kind and its comparison are still declared outside the crate, which is the case this pair is about.

use ingraph::{
  At, Backend, ComplexComparison, Nullable,
  comparison::{
    ToDatabaseComparison,
    sql::{Carrier, SqlConjunction, SqlLoweringError, SqlNullable, push_column},
  },
};

// A filter kind and a comparison declared OUTSIDE this crate, which is the case the wrapper
// composes over.
struct KeyFilter;
struct KeyComparison<V>(Option<V>);

impl<V: Carrier<sqlx::Sqlite>, Db: Backend> ToDatabaseComparison<V, Db> for KeyFilter
where
  KeyComparison<V>: ComplexComparison<Db>,
{
  type Comparison = KeyComparison<V>;
}

impl<V: Carrier<sqlx::Sqlite>> ComplexComparison<sqlx::Sqlite> for KeyComparison<V> {
  fn conjuncts(&self) -> usize {
    usize::from(self.0.is_some())
  }

  fn apply<'q>(
    &'q self,
    at: At<'_>,
    mut builder: SqlConjunction<'q, sqlx::Sqlite>,
  ) -> Result<SqlConjunction<'q, sqlx::Sqlite>, SqlLoweringError> {
    if let Some(value) = &self.0 {
      let qb = builder.open();
      push_column(qb, at);
      qb.push(" = ");
      value.push_bind(qb);
    }
    Ok(builder)
  }
}

type Column =
  <Nullable<KeyFilter> as ToDatabaseComparison<Option<i64>, sqlx::Sqlite>>::Comparison;
let _: Column = SqlNullable::new(KeyComparison::<i64>(None));

so the is-null-as-an-operand spelling is not a question with a bad answer, it is a type that does not exist (E0308):

ⓘ
use ingraph::{
  At, Backend, ComplexComparison, Nullable,
  comparison::{
    ToDatabaseComparison,
    sql::{Carrier, SqlConjunction, SqlLoweringError, SqlNullable, push_column},
  },
};

struct KeyFilter;
struct KeyComparison<V>(Option<V>);

impl<V: Carrier<sqlx::Sqlite>, Db: Backend> ToDatabaseComparison<V, Db> for KeyFilter
where
  KeyComparison<V>: ComplexComparison<Db>,
{
  type Comparison = KeyComparison<V>;
}

impl<V: Carrier<sqlx::Sqlite>> ComplexComparison<sqlx::Sqlite> for KeyComparison<V> {
  fn conjuncts(&self) -> usize {
    usize::from(self.0.is_some())
  }

  fn apply<'q>(
    &'q self,
    at: At<'_>,
    mut builder: SqlConjunction<'q, sqlx::Sqlite>,
  ) -> Result<SqlConjunction<'q, sqlx::Sqlite>, SqlLoweringError> {
    if let Some(value) = &self.0 {
      let qb = builder.open();
      push_column(qb, at);
      qb.push(" = ");
      value.push_bind(qb);
    }
    Ok(builder)
  }
}

type Column =
  <Nullable<KeyFilter> as ToDatabaseComparison<Option<i64>, sqlx::Sqlite>>::Comparison;
let _: Column = SqlNullable::new(KeyComparison::<Option<i64>>(None));

The two earn their keep only together, and they fail in opposite directions. Widening this impl’s header back to V makes Column resolve to SqlNullable<KeyComparison<Option<u128>>>, which reds the FIRST block on E0308 and makes the SECOND compile — and a compile_fail block that compiles is a failing test. Neither block alone would notice.

§The wrapper pays nothing for the crossing’s item bound, and that is the composition working

SqlNullable<C> lowers when C does, and C here is F::Comparison — which already carries ComplexComparison<Db> because the inner crossing promised it. So this row states the DATABASE’s half of the lowering bound and nothing at all about the operand, exactly as the lowering impl below does. Wrapping a kind whose lowering is concrete per dialect is still the same one line as wrapping a kind whose lowering is generic.

Source§

impl<F, V> ToDatabaseComparison<Option<V>, Mongo> for Nullable<F>

Available on crate feature mongo only.

The nullable filter crosses into the nullable comparison over whatever its inner kind crosses into — one impl for every kind, present and future.

The Option lands HERE and nowhere below it, for the reason SqlNullable’s own row gives at length: the storage type this impl is asked for is the COLUMN’s, so a nullable column names Option<V> and V is what the inner comparison is built over. Without it, eq: Some(None) and null: Some(true) would be two spellings of one question — and here the first of them is the wrong one twice over, since {field: {$eq: null}} is this wrapper’s key rather than an operand’s.

It does not overlap the SQL family’s row for the same self type, for the coherence reason MongoScalarComparison’s row records: that one is keyed on Db: sqlx::Database, which is FOREIGN, and Mongo is local and has no such impl. This row naming Mongo concretely is the whole of what keeps the two apart.

Source§

impl<T, CF, Db> ToDatabaseComparison<BarcodeDetection<T>, Db> for BarcodeDetectionFilter<CF>

Available on crate feature sqlx only.

THE ROUTING ROW for a barcode-detection column.

Source§

impl<T, CF, Db> ToDatabaseComparison<BoundingBox<T>, Db> for BoundingBoxFilter<CF>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>>, CF: ToDatabaseComparison<T, Db>,

Available on crate feature sqlx only.

THE ROUTING ROW for a rectangle column.

Source§

impl<T, CF, Db> ToDatabaseComparison<DocumentSegment<T>, Db> for DocumentSegmentFilter<CF>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>>, SqlScalarComparison<Score, Db>: ComplexComparison<Db>, CF: ToDatabaseComparison<T, Db>,

Available on crate feature sqlx only.

THE ROUTING ROW for a document-segment column.

Source§

impl<T, CF, Db> ToDatabaseComparison<LocatedDetection<T>, Db> for LocatedDetectionFilter<CF>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>>, SqlDetectionComparison<Db>: ComplexComparison<Db>, CF: ToDatabaseComparison<T, Db>,

Available on crate feature sqlx only.

THE ROUTING ROW for a located-detection column — reached by a LocatedDetectionFilter over whatever filter the geometry component’s own family routes with.

Source§

impl<T, CF, Db> ToDatabaseComparison<Point2<T>, Db> for Point2Filter<CF>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>>, CF: ToDatabaseComparison<T, Db>,

Available on crate feature sqlx only.

THE ROUTING ROW — a Point2<T> column is reached by a Point2Filter over whatever filter the component’s own family routes with.

Source§

impl<T, CF, Db> ToDatabaseComparison<Quad<T>, Db> for QuadFilter<CF>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>>, CF: ToDatabaseComparison<T, Db>,

Available on crate feature sqlx only.

THE ROUTING ROW for a quadrilateral column.

Source§

impl<T, CF, Db> ToDatabaseComparison<TextDetection<T>, Db> for TextDetectionFilter<CF>

Available on crate feature sqlx only.

THE ROUTING ROW for a text-detection column.

Source§

impl<TF, P, Db> ToDatabaseComparison<TimeRanged<P>, Db> for TimeRangedFilter<TF>
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, Timestamp: Carrier<Db> + ColumnKind, TF: ToDatabaseComparison<P, Db>, P: ColumnKind,

Available on crate feature sqlx only.

THE ROUTING ROW, and it reaches every payload whose filter routes on its own type.

The storage type is TimeRanged<P> rather than the pair (Timestamp, V) DetectedLanguageFilter’s row spells, and the divergence is argued rather than inherited. A pair names how the columns are BOUND; this kind also has to know how many there ARE, and a width is the DOMAIN type’s — so a routing row producing SqlTimeRangedComparison<P, …> from (Timestamp, V) alone cannot name P at all. Spelling the storage type as TimeRanged<P> is what carries both facts, and it is honest: a timed payload column IS stored as a timed payload.

What it does NOT reach is a payload whose own filter routes on a PAIR — a detection, whose row is ToDatabaseComparison<(String, Score), _>. Such a column is reached by NAMING the comparison, which is how every composite-element party in this crate is reached today and for the same reason: see SqlCompositeEdgeComparison, whose own note records that it is named rather than routed. The driving lane names both.

Source§

impl<TF, P> ToDatabaseComparison<TimeRanged<P>, Mongo> for TimeRangedFilter<TF>

Available on crate feature mongo only.

THE ROUTING ROW, and it reaches every payload whose filter routes on its own type — the SQL twin’s shape and its argument, which is that a width is the domain type’s.

Source§

impl<V, Db> ToDatabaseComparison<V, Db> for BooleanFilter
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, V: Carrier<Db>,

Available on crate feature sqlx only.

The bounds are the LOWERING’s, restated — which is what the crossing’s item bound costs a row whose comparison lowers under one generic impl. Db: sqlx::Database stays at the head of them for the coherence reason SqlScalarComparison’s row records.

Source§

impl<V, Db> ToDatabaseComparison<V, Db> for ConfidenceFilter
where Db: Database + for<'q> Backend<Builder<'q> = SqlConjunction<'q, Db>, Buffer: Display>, V: Carrier<Db> + ColumnKind,

Available on crate feature sqlx only.

The confidence kind’s storage-side answer, and it is ScalarFilter’s row above with one parameter fewer: there is no D to carry, the operand being the same widthless ConfidenceOperand at every column.

Every bound is the row above’s, unchanged, and for the same reasons — including Db: sqlx::Database at the head, which is what keeps this from overlapping the MongoDB family’s.

Source§

impl<V: MongoCarrier> ToDatabaseComparison<V, Mongo> for BooleanFilter

Available on crate feature mongo only.

One backend, so one row — and the header is concrete for the coherence reason MongoScalarComparison’s records.

Source§

impl<V: MongoCarrier> ToDatabaseComparison<V, Mongo> for ConfidenceFilter

Available on crate feature mongo only.

The CONFIDENCE kind’s two rows, and they are the SQL family’s word for word with the dialect parameter gone — see SqlScalarComparison’s pair, where the whole argument is: a widthless operand gets its width from the COLUMN’s storage type, and V: ScoreKind is the row that supplies it.

Source§

impl<V: MongoCarrier> ToDatabaseComparison<V, Mongo> for DurationFilter

Available on crate features jiff and mongo only.

One backend, so one row — and the header is concrete for the coherence reason MongoScalarComparison’s records.

V is open here and the CROSSING below is not, which is the split ToDatabaseComparison’s own note describes: a storage form is a declaration rather than a law, so a column that declares its own converter reaches any carrier this backend has, while a column that declares none reaches the one this crate answers with.

Source§

impl<V> ToDatabaseComparison<V, MySql> for DurationFilter
where V: Carrier<MySql>,

Available on crate features jiff and mysql and sqlx only.

See the Postgres row for what the crossing’s item bound adds to a per-dialect map, and for why SQLite’s absence is not something it can fill.

Source§

impl<V> ToDatabaseComparison<V, Postgres> for DurationFilter
where V: Carrier<Postgres>,

Available on crate features jiff and postgres and sqlx only.

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.