Skip to main content

Column

Struct Column 

Source
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 expressionIntoExpr renders the qualified, quoted identifier, so it drops into any Layer 1 slot (select::columns, select::order_by, a join condition);
  • the filter origingte and friends take the column’s Rust type, so age().gte(21) compiles and age().gte("x") does not;
  • the alias carrieraliased_as re-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>

Source

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.

Source

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.

Source

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

The table (or alias) this column renders under.

Source

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.

Source

pub fn expr(self) -> Expr

The qualified, quoted identifier expression: "users"."age".

Source

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.

Source

pub fn is_not_null(self) -> Filter

self IS NOT NULL.

Source§

impl<T: ToValue> Column<T>

Source

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 error
Source

pub fn ne(self, value: impl Into<T>) -> Filter

self <> $n.

Source

pub fn lt(self, value: impl Into<T>) -> Filter

self < $n.

Source

pub fn lte(self, value: impl Into<T>) -> Filter

self <= $n.

Source

pub fn gt(self, value: impl Into<T>) -> Filter

self > $n.

Source

pub fn gte(self, value: impl Into<T>) -> Filter

self >= $n.

Source

pub fn in_(self, values: impl IntoIterator<Item = impl Into<T>>) -> Filter

self IN ($1, $2, …), every element bound.

Source

pub fn not_in(self, values: impl IntoIterator<Item = impl Into<T>>) -> Filter

self NOT IN ($1, $2, …).

Source

pub fn between(self, low: impl Into<T>, high: impl Into<T>) -> Filter

self BETWEEN $1 AND $2.

Source§

impl Column<String>

Source

pub fn like(self, pattern: impl Into<String>) -> Filter

self LIKE $n. Text columns only — a pattern match against a number is a type error here rather than an engine surprise.

Trait Implementations§

Source§

impl<T> Clone for Column<T>

Source§

fn clone(&self) -> Self

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<T> Copy for Column<T>

Source§

impl<T> Debug for Column<T>

Source§

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

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

impl<T> IntoExpr for Column<T>

Source§

fn into_expr(self) -> Expr

Perform the conversion.
Source§

impl<T> IntoExprList for Column<T>

Source§

fn into_expr_list(self) -> Vec<Expr>

Perform the conversion.

Auto Trait Implementations§

§

impl<T> Freeze for Column<T>

§

impl<T> RefUnwindSafe for Column<T>

§

impl<T> Send for Column<T>

§

impl<T> Sync for Column<T>

§

impl<T> Unpin for Column<T>

§

impl<T> UnsafeUnpin for Column<T>

§

impl<T> UnwindSafe for Column<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> 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.