pub struct FieldRef<M, T> { /* private fields */ }Implementations§
Source§impl<M, T> FieldRef<M, T>
impl<M, T> FieldRef<M, T>
pub const fn new(column: &'static str) -> Self
Sourcepub const fn column_name(self) -> &'static str
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
Source§impl<M, T> FieldRef<M, T>
impl<M, T> FieldRef<M, T>
pub fn eq<V>(self, value: V) -> Filterwhere
V: IntoSqlValue,
pub fn ne<V>(self, value: V) -> Filterwhere
V: IntoSqlValue,
pub fn in_<I, V>(self, values: I) -> Filterwhere
I: IntoIterator<Item = V>,
V: IntoSqlValue,
pub fn lt<V>(self, value: V) -> Filterwhere
V: IntoSqlValue,
pub fn lte<V>(self, value: V) -> Filterwhere
V: IntoSqlValue,
pub fn gt<V>(self, value: V) -> Filterwhere
V: IntoSqlValue,
pub fn gte<V>(self, value: V) -> Filterwhere
V: IntoSqlValue,
Sourcepub fn eq_or_null<V>(self, value: V) -> Filterwhere
V: IntoSqlValue,
pub fn eq_or_null<V>(self, value: V) -> Filterwhere
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.
Sourcepub fn match_optional<V>(self, value: Option<V>) -> Option<Filter>where
V: IntoSqlValue,
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, T> FieldRef<M, T>
impl<M, T> FieldRef<M, T>
Sourcepub fn json_has_key(self, key: impl Into<String>) -> FilterExpr
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).
Sourcepub fn json_get_text(self, key: impl Into<String>) -> JsonTextPath
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.
Sourcepub fn covers_geography(self, point: SpatialPoint) -> FilterExpr
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.
Sourcepub fn dwithin_geography(
self,
point: SpatialPoint,
radius_meters: f64,
) -> FilterExpr
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).