Skip to main content

FieldRef

Struct FieldRef 

pub struct FieldRef<M, T> { /* private fields */ }

Implementations§

§

impl<M, T> FieldRef<M, T>

pub const fn new(column: &'static str) -> FieldRef<M, T>

pub const fn column_name(self) -> &'static str

The underlying SQL column name. Exposed so AST-builder helpers like super::coalesce::coalesce can interop with the typed FieldRef API without giving up generic-column flexibility.

pub fn asc(self) -> OrderClause

pub fn desc(self) -> OrderClause

§

impl<M, T> FieldRef<M, T>

pub fn eq<V>(self, value: V) -> Filter
where V: IntoSqlValue,

pub fn ne<V>(self, value: V) -> Filter
where V: IntoSqlValue,

pub fn in_<I, V>(self, values: I) -> Filter
where I: IntoIterator<Item = V>, V: IntoSqlValue,

pub fn lt<V>(self, value: V) -> Filter
where V: IntoSqlValue,

pub fn lte<V>(self, value: V) -> Filter
where V: IntoSqlValue,

pub fn gt<V>(self, value: V) -> Filter
where V: IntoSqlValue,

pub fn gte<V>(self, value: V) -> Filter
where V: IntoSqlValue,

pub fn eq_or_null<V>(self, value: V) -> Filter
where V: IntoSqlValue,

Match rows where the column is null OR equals value. The canonical inline-SQL workaround for “filter only if the caller provided this value, otherwise let nulls through” — schemas with sparse, optional foreign-key-style columns hit this constantly. Renders as (col IS NULL OR col = $1).

Use Self::match_optional when the caller’s value is itself an Option — that variant skips the filter entirely on None instead of binding a null.

pub fn match_optional<V>(self, value: Option<V>) -> Option<Filter>
where V: IntoSqlValue,

Filter on equality when the caller has a value, skip the filter entirely when they don’t. Returns None for the no-op case so callers can plumb it through [crate::FilterExpr::any_of_optional]-style helpers, or feed it directly into a where_optional(...) builder method on the query builders.

The emitted filter is the same (col IS NULL OR col = $1) as Self::eq_or_null — when the caller did supply a value, we still let nulls through, matching the canonical “optional-equality with null-as-wildcard” semantics from the inline-SQL pattern.

§

impl<M> FieldRef<M, bool>

pub fn is_true(self) -> Filter

pub fn is_false(self) -> Filter

§

impl<M> FieldRef<M, String>

pub fn contains(self, value: impl Into<String>) -> Filter

pub fn starts_with(self, value: impl Into<String>) -> Filter

§

impl<M, T> FieldRef<M, Option<T>>

pub fn is_null(self) -> Filter

pub fn is_not_null(self) -> Filter

§

impl<M> FieldRef<M, Option<String>>

pub fn contains(self, value: impl Into<String>) -> Filter

pub fn starts_with(self, value: impl Into<String>) -> Filter

§

impl<M, T> FieldRef<M, T>

pub fn json_has_key(self, key: impl Into<String>) -> FilterExpr

PG: col ? 'key' — the JSON document contains key as a top-level field. SQLite (no native ? operator): lowers to json_extract(col, '$.key') IS NOT NULL.

Intended for jsonb / JSON columns. Using this on a non-JSON column compiles fine but errors at the engine layer when the SQL runs — Rust’s type system doesn’t gate this for you.

The key is taken as impl Into<String> so callers can pass either a &'static str literal or a runtime-owned String (e.g. user-driven analytics queries that pivot on a metric name from the request).

pub fn json_get_text(self, key: impl Into<String>) -> JsonTextPath

PG: col ->> 'key' <op> $1 — extract the value at key as text, then compare. SQLite: json_extract(col, '$.key') <op> $1. Returns a JsonTextPath that supports the standard comparison ops via chained methods. See Self::json_has_key for the key-ownership rationale.

pub fn covers_geography(self, point: SpatialPoint) -> FilterExpr

PG-only: ST_Covers(col::geography, point::geography) — the column’s geography contains point (including boundary). Use for “is this caller-supplied point inside the row’s service area” filters on geography(Polygon, 4326) columns.

The embedded rusqlite backend doesn’t ship SpatiaLite, so this filter fails loud at the render layer there. Document at the schema level whether a model supports the embedded backend at all before using spatial ops on it.

pub fn dwithin_geography( self, point: SpatialPoint, radius_meters: f64, ) -> FilterExpr

PG-only: ST_DWithin(col::geography, point::geography, radius_meters) — the column’s geography is within radius_meters of the given point (great-circle distance, since ::geography triggers the spheroid path).

Trait Implementations§

§

impl<M, T> Clone for FieldRef<M, T>
where M: Clone, T: Clone,

§

fn clone(&self) -> FieldRef<M, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<M, T> Debug for FieldRef<M, T>
where M: Debug, T: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<M, T> IntoColumnName for FieldRef<M, T>

§

fn into_column_name(self) -> &'static str

§

impl<M, T> Copy for FieldRef<M, T>
where M: Copy, T: Copy,

Auto Trait Implementations§

§

impl<M, T> Freeze for FieldRef<M, T>

§

impl<M, T> RefUnwindSafe for FieldRef<M, T>

§

impl<M, T> Send for FieldRef<M, T>

§

impl<M, T> Sync for FieldRef<M, T>

§

impl<M, T> Unpin for FieldRef<M, T>

§

impl<M, T> UnsafeUnpin for FieldRef<M, T>

§

impl<M, T> UnwindSafe for FieldRef<M, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,