Skip to main content

FieldRef

Struct FieldRef 

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

Implementations§

Source§

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

Source

pub const fn new(column: &'static str) -> Self

Source

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.

Source

pub fn asc(self) -> OrderClause

Source

pub fn desc(self) -> OrderClause

Source§

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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.

Source

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.

Source§

impl<M> FieldRef<M, bool>

Source

pub fn is_true(self) -> Filter

Source

pub fn is_false(self) -> Filter

Source§

impl<M> FieldRef<M, String>

Source

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

Source

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

Source§

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

Source

pub fn is_null(self) -> Filter

Source

pub fn is_not_null(self) -> Filter

Source§

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

Source

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

Source

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

Source§

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

Source

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).

Source

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.

Source§

impl<M> FieldRef<M, Vec<f32>>

Source

pub fn distance_to( self, metric: VectorMetric, query_vector: Vec<f32>, ) -> VectorDistanceExpr

Left-hand operand of a Vector(n) distance comparison (see docs/design/extensions.md §6/§7, cratestack#163) — chain a comparator (.lt/.lte/.gt/.gte/.eq) for a threshold filter, or .asc/.desc to use it as an ORDER BY target. The metric is never inferred from an index (a similarity search must keep working with no vector index present, per AC #2 on cratestack#163) — pass it explicitly, or derive it from a known index opclass via VectorMetric::from_opclass.

PG-only (pgvector); the embedded rusqlite backend fails loud at render time if reached, mirroring [Self::covers_geography].

Source

pub fn order_by_distance( self, metric: VectorMetric, query_vector: Vec<f32>, ) -> OrderClause

Shorthand for distance_to(metric, query_vector).asc() — order by distance, nearest first, the standard k-NN similarity-search shape.

Source§

impl<M> FieldRef<M, Option<Vec<f32>>>

Source

pub fn distance_to( self, metric: VectorMetric, query_vector: Vec<f32>, ) -> VectorDistanceExpr

Same as FieldRef::<M, Vec<f32>>::distance_to for a nullable Vector(n) column. Rows with a NULL vector compare as NULL distance, which sorts last under the framework’s default NULLS LAST ordering (crate::NullOrder) and never matches a threshold filter.

Source

pub fn order_by_distance( self, metric: VectorMetric, query_vector: Vec<f32>, ) -> OrderClause

Shorthand for distance_to(metric, query_vector).asc().

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

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

Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

fn into_column_name(self) -> &'static str

Auto Trait Implementations§

§

impl<M, T> Freeze for FieldRef<M, T>
where PhantomData<fn() -> (M, T)>: Freeze,

§

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

§

impl<M, T> Send for FieldRef<M, T>
where PhantomData<fn() -> (M, T)>: Send,

§

impl<M, T> Sync for FieldRef<M, T>
where PhantomData<fn() -> (M, T)>: Sync,

§

impl<M, T> Unpin for FieldRef<M, T>
where PhantomData<fn() -> (M, T)>: Unpin,

§

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.

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> 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 = !

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.