pub struct Column<T> { /* private fields */ }Expand description
A model’s column: the one entry point for everything a column is used for.
bob splits a column across four generated surfaces (ColumnNames,
Columns, SelectWhere, Preload); keelson deliberately unifies them.
users::age() is
- the column expression —
IntoExprrenders the qualified, quoted identifier, so it drops into any Layer 1 slot (select::columns,select::order_by, a join condition); - the filter origin —
gteand friends take the column’s Rust type, soage().gte(21)compiles andage().gte("x")does not; - the alias carrier —
aliased_asre-qualifies it when the query aliases the table.
The type parameter is the column’s Rust type from
docs/type-mappings.md (the base type; nullability lives on the row
struct’s Option, not here — a comparison against NULL is never what
= $1 means in SQL, which is why is_null is its own
method rather than eq(None)).
Implementations§
Source§impl<T> Column<T>
impl<T> Column<T>
Sourcepub const fn new(table: &'static str, name: &'static str) -> Column<T>
pub const fn new(table: &'static str, name: &'static str) -> Column<T>
The column table.name. Generated code calls this; nothing checks
the names — the schema they came from is the generator’s authority.
Sourcepub const fn aliased_as(self, alias: &'static str) -> Column<T>
pub const fn aliased_as(self, alias: &'static str) -> Column<T>
The same column under a table alias: when the query says
FROM "users" AS "u", users::age().aliased_as("u") renders
"u"."age". The type is carried along — an aliased column is exactly
as typed as the original.
Sourcepub const fn name(&self) -> &'static str
pub const fn name(&self) -> &'static str
The bare column name — what the result-set column is called, and what
FromRow reads it back by.
Sourcepub fn is_null(self) -> Filter
pub fn is_null(self) -> Filter
self IS NULL. On any column: nullability is the schema’s fact, and a
filter on a NOT NULL column is merely always false.
Sourcepub fn is_not_null(self) -> Filter
pub fn is_not_null(self) -> Filter
self IS NOT NULL.
Source§impl<T: ToValue> Column<T>
impl<T: ToValue> Column<T>
Sourcepub fn eq(self, value: impl Into<T>) -> Filter
pub fn eq(self, value: impl Into<T>) -> Filter
self = $n, binding the value.
The comparison is typed by the column: the value must convert into the column’s Rust type, so a mistyped literal fails to compile —
let age: keelson_models::Column<i32> = keelson_models::Column::new("users", "age");
age.gte("x"); // a &str is not an i32: compile errorSourcepub fn in_(self, values: impl IntoIterator<Item = impl Into<T>>) -> Filter
pub fn in_(self, values: impl IntoIterator<Item = impl Into<T>>) -> Filter
self IN ($1, $2, …), every element bound.
Sourcepub fn not_in(self, values: impl IntoIterator<Item = impl Into<T>>) -> Filter
pub fn not_in(self, values: impl IntoIterator<Item = impl Into<T>>) -> Filter
self NOT IN ($1, $2, …).