pub struct Column<T> {
pub name: &'static str,
pub aliased_name: &'static str,
pub table_alias: &'static str,
pub _marker: PhantomData<T>,
}
Expand description
Represents a database column in a type-safe way.
Column<T>
is a lightweight wrapper around a column name (&'static str
)
with a phantom type parameter T
that indicates the type of values
that can be bound to conditions involving this column.
This allows you to write type-safe query conditions such as:
use sqlorm_core::qb::{Column, Condition};
use std::marker::PhantomData;
static ID: Column<i32> = Column { name: "id", table_alias: "user__", _marker: PhantomData };
let cond: Condition = ID.eq(42);
assert_eq!(cond.sql, "user__.id = ?");
Fields§
§name: &'static str
The column name as it appears in SQL.
aliased_name: &'static str
The column name with table alias, as it appears in SQL.
example: __user.id
table_alias: &'static str
The table alias to use when generating SQL conditions.
_marker: PhantomData<T>
Marker to carry the type information for the column.
Implementations§
Source§impl<T> Column<T>
impl<T> Column<T>
Sourcepub fn in_(self, vals: Vec<T>) -> Condition
pub fn in_(self, vals: Vec<T>) -> Condition
Create a condition: column IN (?, ?, ...)
The number of placeholders matches the number of values provided.
Panics if vals
is empty
Sourcepub fn not_in(self, vals: Vec<T>) -> Condition
pub fn not_in(self, vals: Vec<T>) -> Condition
Create a condition: column NOT IN (?, ?, ...)
Panics if vals
is empty
Sourcepub fn is_not_null(self) -> Condition
pub fn is_not_null(self) -> Condition
Create a condition: column IS NOT NULL
Sourcepub fn not_between(self, start: T, end: T) -> Condition
pub fn not_between(self, start: T, end: T) -> Condition
Create a condition: column NOT BETWEEN ? AND ?
Trait Implementations§
impl<T> Copy for Column<T>
Auto Trait Implementations§
impl<T> Freeze for Column<T>
impl<T> RefUnwindSafe for Column<T>where
T: RefUnwindSafe,
impl<T> Send for Column<T>where
T: Send,
impl<T> Sync for Column<T>where
T: Sync,
impl<T> Unpin for Column<T>where
T: Unpin,
impl<T> UnwindSafe for Column<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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