Trait ColumnTrait
pub trait ColumnTrait:
IdenStatic
+ IntoEnumIterator
+ FromStr {
type EntityName: EntityName;
Show 34 methods
// Required method
fn def(&self) -> ColumnDef;
// Provided methods
fn enum_type_name(&self) -> Option<&'static str> { ... }
fn entity_name(&self) -> SeaRc<dyn Iden> { ... }
fn as_column_ref(&self) -> (SeaRc<dyn Iden>, SeaRc<dyn Iden>) { ... }
fn eq<V>(&self, v: V) -> SimpleExpr
where V: Into<Value> { ... }
fn ne<V>(&self, v: V) -> SimpleExpr
where V: Into<Value> { ... }
fn gt<V>(&self, v: V) -> SimpleExpr
where V: Into<Value> { ... }
fn gte<V>(&self, v: V) -> SimpleExpr
where V: Into<Value> { ... }
fn lt<V>(&self, v: V) -> SimpleExpr
where V: Into<Value> { ... }
fn lte<V>(&self, v: V) -> SimpleExpr
where V: Into<Value> { ... }
fn between<V>(&self, a: V, b: V) -> SimpleExpr
where V: Into<Value> { ... }
fn not_between<V>(&self, a: V, b: V) -> SimpleExpr
where V: Into<Value> { ... }
fn like<T>(&self, s: T) -> SimpleExpr
where T: IntoLikeExpr { ... }
fn not_like<T>(&self, s: T) -> SimpleExpr
where T: IntoLikeExpr { ... }
fn starts_with<T>(&self, s: T) -> SimpleExpr
where T: Into<String> { ... }
fn ends_with<T>(&self, s: T) -> SimpleExpr
where T: Into<String> { ... }
fn contains<T>(&self, s: T) -> SimpleExpr
where T: Into<String> { ... }
fn max(&self) -> SimpleExpr { ... }
fn min(&self) -> SimpleExpr { ... }
fn sum(&self) -> SimpleExpr { ... }
fn count(&self) -> SimpleExpr { ... }
fn is_null(&self) -> SimpleExpr { ... }
fn is_not_null(&self) -> SimpleExpr { ... }
fn if_null<V>(&self, v: V) -> SimpleExpr
where V: Into<Value> { ... }
fn is_in<V, I>(&self, v: I) -> SimpleExpr
where V: Into<Value>,
I: IntoIterator<Item = V> { ... }
fn is_not_in<V, I>(&self, v: I) -> SimpleExpr
where V: Into<Value>,
I: IntoIterator<Item = V> { ... }
fn in_subquery(&self, s: SelectStatement) -> SimpleExpr { ... }
fn not_in_subquery(&self, s: SelectStatement) -> SimpleExpr { ... }
fn into_expr(self) -> Expr { ... }
fn into_returning_expr(self, db_backend: DatabaseBackend) -> Expr { ... }
fn select_as(&self, expr: Expr) -> SimpleExpr { ... }
fn select_enum_as(&self, expr: Expr) -> SimpleExpr { ... }
fn save_as(&self, val: Expr) -> SimpleExpr { ... }
fn save_enum_as(&self, val: Expr) -> SimpleExpr { ... }
}Expand description
API for working with a Column. Mostly a wrapper of the identically named methods in sea_query::Expr
Required Associated Types§
type EntityName: EntityName
Required Methods§
Provided Methods§
fn enum_type_name(&self) -> Option<&'static str>
fn enum_type_name(&self) -> Option<&'static str>
Get the enum name of the column type
fn entity_name(&self) -> SeaRc<dyn Iden>
fn entity_name(&self) -> SeaRc<dyn Iden>
Get the name of the entity the column belongs to
fn as_column_ref(&self) -> (SeaRc<dyn Iden>, SeaRc<dyn Iden>)
fn as_column_ref(&self) -> (SeaRc<dyn Iden>, SeaRc<dyn Iden>)
get the name of the entity the column belongs to
fn eq<V>(&self, v: V) -> SimpleExpr
fn ne<V>(&self, v: V) -> SimpleExpr
fn gt<V>(&self, v: V) -> SimpleExpr
fn gte<V>(&self, v: V) -> SimpleExpr
fn lt<V>(&self, v: V) -> SimpleExpr
fn lte<V>(&self, v: V) -> SimpleExpr
fn between<V>(&self, a: V, b: V) -> SimpleExpr
fn between<V>(&self, a: V, b: V) -> SimpleExpr
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.filter(cake::Column::Id.between(2, 3))
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`id` BETWEEN 2 AND 3"
);fn not_between<V>(&self, a: V, b: V) -> SimpleExpr
fn not_between<V>(&self, a: V, b: V) -> SimpleExpr
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.filter(cake::Column::Id.not_between(2, 3))
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`id` NOT BETWEEN 2 AND 3"
);fn like<T>(&self, s: T) -> SimpleExprwhere
T: IntoLikeExpr,
fn like<T>(&self, s: T) -> SimpleExprwhere
T: IntoLikeExpr,
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.filter(cake::Column::Name.like("cheese"))
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`name` LIKE 'cheese'"
);fn not_like<T>(&self, s: T) -> SimpleExprwhere
T: IntoLikeExpr,
fn not_like<T>(&self, s: T) -> SimpleExprwhere
T: IntoLikeExpr,
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.filter(cake::Column::Name.not_like("cheese"))
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`name` NOT LIKE 'cheese'"
);fn starts_with<T>(&self, s: T) -> SimpleExpr
fn starts_with<T>(&self, s: T) -> SimpleExpr
This is a simplified shorthand for a more general like method.
Use like if you need something more complex, like specifying an escape character.
§Examples
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.filter(cake::Column::Name.starts_with("cheese"))
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`name` LIKE 'cheese%'"
);fn ends_with<T>(&self, s: T) -> SimpleExpr
fn ends_with<T>(&self, s: T) -> SimpleExpr
This is a simplified shorthand for a more general like method.
Use like if you need something more complex, like specifying an escape character.
§Examples
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.filter(cake::Column::Name.ends_with("cheese"))
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`name` LIKE '%cheese'"
);fn contains<T>(&self, s: T) -> SimpleExpr
fn contains<T>(&self, s: T) -> SimpleExpr
This is a simplified shorthand for a more general like method.
Use like if you need something more complex, like specifying an escape character.
§Examples
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.filter(cake::Column::Name.contains("cheese"))
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`name` LIKE '%cheese%'"
);fn max(&self) -> SimpleExpr
fn max(&self) -> SimpleExpr
See also SeaQuery’s method with same name.
fn min(&self) -> SimpleExpr
fn min(&self) -> SimpleExpr
See also SeaQuery’s method with same name.
fn sum(&self) -> SimpleExpr
fn sum(&self) -> SimpleExpr
See also SeaQuery’s method with same name.
fn count(&self) -> SimpleExpr
fn count(&self) -> SimpleExpr
See also SeaQuery’s method with same name.
fn is_null(&self) -> SimpleExpr
fn is_null(&self) -> SimpleExpr
See also SeaQuery’s method with same name.
fn is_not_null(&self) -> SimpleExpr
fn is_not_null(&self) -> SimpleExpr
See also SeaQuery’s method with same name.
fn if_null<V>(&self, v: V) -> SimpleExpr
fn if_null<V>(&self, v: V) -> SimpleExpr
Perform an operation if the column is null
fn is_in<V, I>(&self, v: I) -> SimpleExpr
fn is_not_in<V, I>(&self, v: I) -> SimpleExpr
fn in_subquery(&self, s: SelectStatement) -> SimpleExpr
fn not_in_subquery(&self, s: SelectStatement) -> SimpleExpr
fn into_expr(self) -> Expr
fn into_expr(self) -> Expr
Construct a SimpleExpr::Column wrapped in Expr.
fn into_returning_expr(self, db_backend: DatabaseBackend) -> Expr
fn into_returning_expr(self, db_backend: DatabaseBackend) -> Expr
Construct a returning Expr.
fn select_as(&self, expr: Expr) -> SimpleExpr
fn select_as(&self, expr: Expr) -> SimpleExpr
Cast column expression used in select statement. It only cast database enum as text if it’s an enum column.
fn select_enum_as(&self, expr: Expr) -> SimpleExpr
fn select_enum_as(&self, expr: Expr) -> SimpleExpr
Cast enum column as text; do nothing if self is not an enum.
fn save_as(&self, val: Expr) -> SimpleExpr
fn save_as(&self, val: Expr) -> SimpleExpr
Cast value of a column into the correct type for database storage. It only cast text as enum type if it’s an enum column.
fn save_enum_as(&self, val: Expr) -> SimpleExpr
fn save_enum_as(&self, val: Expr) -> SimpleExpr
Cast value of an enum column as enum type; do nothing if self is not an enum.
Will also transform Array(Vec<Json>) into Json(Vec<Json>) if the column type is Json.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.