pub trait JsonbPathComparable { }Expand description
Marker for value types that have a correct Postgres cast for a JSONB
path LHS comparison. The comparison surface of
JsonbPathRef<M, V>
(eq/neq/gt/gte/lt/lte/in_list) requires this bound so a
type whose JSONB text extraction would compare incorrectly cannot
reach the comparison API. The flat
path::<V>() constructor stays
unbounded for dynamic paths; the bound applies only when a comparison
is actually built.
§Intentionally NOT comparable
Vec<u8>(BYTEA): raw binary;->>'k'yields the JSON string form, not bytes — comparing it against a BYTEA bind is meaningless.Range<T>: a JSONB range is stored as an object, not a scalar the cast table can target.- array
Vec<V>: a JSONB array, not a scalar. time::PrimitiveDateTime: withouttime/serde-human-readable,timeserializes it into JSONB as a numeric tuple (e.g.[2021,2,3,4,5,0]), not a timestamp string, so(col->>'key')::timestampwould fail at the database. (The same tuple-serialization caveat applies toOffsetDateTime/Dateand is tracked separately in djogi#400; this release keeps them comparable to avoid scope creep.)crate::Interval:djogi::Intervalhas noSerializeimpl, so it cannot be stored in aJsonb<T>field via the typed surface. AJsonbPathRef<M, Interval>comparison would be dead code — there is nothing to compare against. IfIntervalgainsSerializein the future, verify the on-disk encoding is ISO 8601 text before adding an impl here.
§Extending for adopter types
This is an open marker trait — no private seal. Adopters who define
a custom scalar newtype for a JSONB path and override
IntoFilterValue::jsonb_sql_cast
MUST also add a one-line impl djogi::jsonb::JsonbPathComparable for MyType {} so the comparison surface accepts it. The
primary_key! macro emits this impl
automatically for custom PK newtypes. The orphan rule prevents an
adopter crate from implementing this marker for a foreign type such as
Vec<u8>, so the open marker cannot be abused to restore a blocked
built-in.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".