Skip to main content

JsonbPathComparable

Trait JsonbPathComparable 

Source
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: without time/serde-human-readable, time serializes it into JSONB as a numeric tuple (e.g. [2021,2,3,4,5,0]), not a timestamp string, so (col->>'key')::timestamp would fail at the database. (The same tuple-serialization caveat applies to OffsetDateTime/Date and is tracked separately in djogi#400; this release keeps them comparable to avoid scope creep.)
  • crate::Interval: djogi::Interval has no Serialize impl, so it cannot be stored in a Jsonb<T> field via the typed surface. A JsonbPathRef<M, Interval> comparison would be dead code — there is nothing to compare against. If Interval gains Serialize in 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".

Implementations on Foreign Types§

Source§

impl JsonbPathComparable for &'static str

Source§

impl JsonbPathComparable for Date

Source§

impl JsonbPathComparable for Decimal

Source§

impl JsonbPathComparable for OffsetDateTime

Source§

impl JsonbPathComparable for String

Source§

impl JsonbPathComparable for Uuid

Source§

impl JsonbPathComparable for bool

Source§

impl JsonbPathComparable for f32

Source§

impl JsonbPathComparable for f64

Source§

impl JsonbPathComparable for i8

Source§

impl JsonbPathComparable for i16

Source§

impl JsonbPathComparable for i32

Source§

impl JsonbPathComparable for i64

Source§

impl JsonbPathComparable for u8

Source§

impl JsonbPathComparable for u16

Source§

impl JsonbPathComparable for u32

Source§

impl JsonbPathComparable for u64

Implementors§