Try EnumValue
This commit is contained in:
parent
cf52839c3a
commit
2ee376ddd1
@ -245,8 +245,7 @@ impl ColumnType {
|
|||||||
|
|
||||||
pub(crate) fn get_enum_name(&self) -> Option<&String> {
|
pub(crate) fn get_enum_name(&self) -> Option<&String> {
|
||||||
match self {
|
match self {
|
||||||
// FIXME: How to get rid of this feature gate?
|
ColumnType::Enum(s, _) => Some(s),
|
||||||
ColumnType::Enum(s, _) if cfg!(feature = "sqlx-postgres") => Some(s),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
PrimaryKeyTrait, QueryTrait,
|
PrimaryKeyTrait, QueryTrait,
|
||||||
};
|
};
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use sea_query::{Alias, Expr, Func, InsertStatement, ValueTuple};
|
use sea_query::{Expr, InsertStatement, SimpleExpr, ValueTuple};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Insert<A>
|
pub struct Insert<A>
|
||||||
@ -136,7 +136,7 @@ where
|
|||||||
columns.push(col);
|
columns.push(col);
|
||||||
let val = av.into_value().unwrap();
|
let val = av.into_value().unwrap();
|
||||||
let expr = if let Some(enum_name) = enum_name {
|
let expr = if let Some(enum_name) = enum_name {
|
||||||
Func::cast_as(val, Alias::new(enum_name))
|
SimpleExpr::EnumValue(enum_name.to_owned(), Box::new(Expr::val(val).into()))
|
||||||
} else {
|
} else {
|
||||||
Expr::val(val).into()
|
Expr::val(val).into()
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@ use crate::{ColumnTrait, EntityTrait, Iterable, QueryFilter, QueryOrder, QuerySe
|
|||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
pub use sea_query::JoinType;
|
pub use sea_query::JoinType;
|
||||||
use sea_query::{Alias, DynIden, Expr, Func, IntoColumnRef, SeaRc, SelectStatement, SimpleExpr};
|
use sea_query::{DynIden, Expr, IntoColumnRef, SeaRc, SelectStatement, SimpleExpr};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Select<E>
|
pub struct Select<E>
|
||||||
@ -121,7 +121,7 @@ where
|
|||||||
let enum_name = col_def.get_column_type().get_enum_name();
|
let enum_name = col_def.get_column_type().get_enum_name();
|
||||||
let col_expr = Expr::tbl(table.clone(), col);
|
let col_expr = Expr::tbl(table.clone(), col);
|
||||||
if enum_name.is_some() {
|
if enum_name.is_some() {
|
||||||
Func::cast_expr_as(col_expr, Alias::new("text"))
|
SimpleExpr::EnumValue("text".to_owned(), Box::new(col_expr.into()))
|
||||||
} else {
|
} else {
|
||||||
col_expr.into()
|
col_expr.into()
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
QueryTrait,
|
QueryTrait,
|
||||||
};
|
};
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use sea_query::{Alias, Expr, Func, IntoIden, SimpleExpr, UpdateStatement};
|
use sea_query::{Expr, IntoIden, SimpleExpr, UpdateStatement};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Update;
|
pub struct Update;
|
||||||
@ -110,7 +110,7 @@ where
|
|||||||
if av.is_set() {
|
if av.is_set() {
|
||||||
let val = av.into_value().unwrap();
|
let val = av.into_value().unwrap();
|
||||||
let expr = if let Some(enum_name) = enum_name {
|
let expr = if let Some(enum_name) = enum_name {
|
||||||
Func::cast_as(val, Alias::new(enum_name))
|
SimpleExpr::EnumValue(enum_name.to_owned(), Box::new(Expr::val(val).into()))
|
||||||
} else {
|
} else {
|
||||||
Expr::val(val).into()
|
Expr::val(val).into()
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user