Cont. Upgrade to SeaQuery 0.28.0 (#1366)

* Upgrade to SeaQuery 0.28.0

* Remove unnecessary heap allocation

* Upgrade sea-query-binder

* Upgrade sea-schema

* Fix

* Upgrade sea-schema

* refactoring

Co-authored-by: Ivan Krivosheev <py.krivosheev@gmail.com>
This commit is contained in:
Billy Chan 2023-01-05 20:41:28 +08:00 committed by GitHub
parent 8781c03a35
commit e246d3faaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 265 additions and 267 deletions

View File

@ -34,8 +34,8 @@ tracing = { version = "0.1", default-features = false, features = ["attributes",
rust_decimal = { version = "1", default-features = false, optional = true } rust_decimal = { version = "1", default-features = false, optional = true }
bigdecimal = { version = "0.3", default-features = false, optional = true } bigdecimal = { version = "0.3", default-features = false, optional = true }
sea-orm-macros = { version = "0.10.3", path = "sea-orm-macros", default-features = false, optional = true } sea-orm-macros = { version = "0.10.3", path = "sea-orm-macros", default-features = false, optional = true }
sea-query = { version = "0.27.2", features = ["thread-safe"] } sea-query = { version = "0.28", features = ["thread-safe"] }
sea-query-binder = { version = "0.2.2", default-features = false, optional = true } sea-query-binder = { version = "0.3", default-features = false, optional = true }
sea-strum = { version = "0.23", default-features = false, features = ["derive", "sea-orm"] } sea-strum = { version = "0.23", default-features = false, features = ["derive", "sea-orm"] }
serde = { version = "1.0", default-features = false } serde = { version = "1.0", default-features = false }
serde_json = { version = "1.0", default-features = false, optional = true } serde_json = { version = "1.0", default-features = false, optional = true }

View File

@ -125,7 +125,7 @@ let pear = fruit::ActiveModel {
let pear = pear.insert(db).await?; let pear = pear.insert(db).await?;
// insert many // insert many
Fruit::insert_many(vec![apple, pear]).exec(db).await?; Fruit::insert_many([apple, pear]).exec(db).await?;
``` ```
### Update ### Update
```rust ```rust

View File

@ -10,8 +10,8 @@ pub struct Model {
pub updated_at: DateTimeWithTimeZone, pub updated_at: DateTimeWithTimeZone,
pub name: String, pub name: String,
#[sea_orm(column_type = "Text", nullable)] #[sea_orm(column_type = "Text", nullable)]
pub description: Option<String>, pub description: Option<String> ,
pub tag_ids: Vec<u8>, pub tag_ids: Vec<u8> ,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@ -35,7 +35,7 @@ clap = { version = "3.2", default-features = false, features = ["std", "env", "d
dotenvy = { version = "0.15", default-features = false, optional = true } dotenvy = { version = "0.15", default-features = false, optional = true }
async-std = { version = "1.9", default-features = false, features = ["attributes", "tokio1"], optional = true } async-std = { version = "1.9", default-features = false, features = ["attributes", "tokio1"], optional = true }
sea-orm-codegen = { version = "=0.10.3", path = "../sea-orm-codegen", default-features = false, optional = true } sea-orm-codegen = { version = "=0.10.3", path = "../sea-orm-codegen", default-features = false, optional = true }
sea-schema = { version = "0.10.2" } sea-schema = { version = "0.11" }
sqlx = { version = "0.6", default-features = false, features = ["mysql", "postgres"], optional = true } sqlx = { version = "0.6", default-features = false, features = ["mysql", "postgres"], optional = true }
tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt"] } tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt"] }
tracing = { version = "0.1", default-features = false } tracing = { version = "0.1", default-features = false }

View File

@ -17,7 +17,7 @@ name = "sea_orm_codegen"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
sea-query = { version = "0.27.1", default-features = false, features = ["thread-safe"] } sea-query = { version = "0.28", default-features = false, features = ["thread-safe"] }
syn = { version = "1", default-features = false } syn = { version = "1", default-features = false }
quote = { version = "1", default-features = false } quote = { version = "1", default-features = false }
heck = { version = "0.3", default-features = false } heck = { version = "0.3", default-features = false }

View File

@ -152,9 +152,9 @@ impl Entity {
} }
pub fn get_eq_needed(&self) -> TokenStream { pub fn get_eq_needed(&self) -> TokenStream {
fn is_floats(col_type: &sea_query::ColumnType) -> bool { fn is_floats(col_type: &ColumnType) -> bool {
match col_type { match col_type {
ColumnType::Float(_) | ColumnType::Double(_) => true, ColumnType::Float | ColumnType::Double => true,
ColumnType::Array(col_type) => is_floats(col_type), ColumnType::Array(col_type) => is_floats(col_type),
_ => false, _ => false,
} }
@ -199,7 +199,7 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(None), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: false, not_null: false,
unique: false, unique: false,

View File

@ -35,35 +35,35 @@ impl Column {
| ColumnType::String(_) | ColumnType::String(_)
| ColumnType::Text | ColumnType::Text
| ColumnType::Custom(_) => "String".to_owned(), | ColumnType::Custom(_) => "String".to_owned(),
ColumnType::TinyInteger(_) => "i8".to_owned(), ColumnType::TinyInteger => "i8".to_owned(),
ColumnType::SmallInteger(_) => "i16".to_owned(), ColumnType::SmallInteger => "i16".to_owned(),
ColumnType::Integer(_) => "i32".to_owned(), ColumnType::Integer => "i32".to_owned(),
ColumnType::BigInteger(_) => "i64".to_owned(), ColumnType::BigInteger => "i64".to_owned(),
ColumnType::TinyUnsigned(_) => "u8".to_owned(), ColumnType::TinyUnsigned => "u8".to_owned(),
ColumnType::SmallUnsigned(_) => "u16".to_owned(), ColumnType::SmallUnsigned => "u16".to_owned(),
ColumnType::Unsigned(_) => "u32".to_owned(), ColumnType::Unsigned => "u32".to_owned(),
ColumnType::BigUnsigned(_) => "u64".to_owned(), ColumnType::BigUnsigned => "u64".to_owned(),
ColumnType::Float(_) => "f32".to_owned(), ColumnType::Float => "f32".to_owned(),
ColumnType::Double(_) => "f64".to_owned(), ColumnType::Double => "f64".to_owned(),
ColumnType::Json | ColumnType::JsonBinary => "Json".to_owned(), ColumnType::Json | ColumnType::JsonBinary => "Json".to_owned(),
ColumnType::Date => match date_time_crate { ColumnType::Date => match date_time_crate {
DateTimeCrate::Chrono => "Date".to_owned(), DateTimeCrate::Chrono => "Date".to_owned(),
DateTimeCrate::Time => "TimeDate".to_owned(), DateTimeCrate::Time => "TimeDate".to_owned(),
}, },
ColumnType::Time(_) => match date_time_crate { ColumnType::Time => match date_time_crate {
DateTimeCrate::Chrono => "Time".to_owned(), DateTimeCrate::Chrono => "Time".to_owned(),
DateTimeCrate::Time => "TimeTime".to_owned(), DateTimeCrate::Time => "TimeTime".to_owned(),
}, },
ColumnType::DateTime(_) => match date_time_crate { ColumnType::DateTime => match date_time_crate {
DateTimeCrate::Chrono => "DateTime".to_owned(), DateTimeCrate::Chrono => "DateTime".to_owned(),
DateTimeCrate::Time => "TimeDateTime".to_owned(), DateTimeCrate::Time => "TimeDateTime".to_owned(),
}, },
ColumnType::Timestamp(_) => match date_time_crate { ColumnType::Timestamp => match date_time_crate {
DateTimeCrate::Chrono => "DateTimeUtc".to_owned(), DateTimeCrate::Chrono => "DateTimeUtc".to_owned(),
// ColumnType::Timpestamp(_) => time::PrimitiveDateTime: https://docs.rs/sqlx/0.3.5/sqlx/postgres/types/index.html#time // ColumnType::Timpestamp(_) => time::PrimitiveDateTime: https://docs.rs/sqlx/0.3.5/sqlx/postgres/types/index.html#time
DateTimeCrate::Time => "TimeDateTime".to_owned(), DateTimeCrate::Time => "TimeDateTime".to_owned(),
}, },
ColumnType::TimestampWithTimeZone(_) => match date_time_crate { ColumnType::TimestampWithTimeZone => match date_time_crate {
DateTimeCrate::Chrono => "DateTimeWithTimeZone".to_owned(), DateTimeCrate::Chrono => "DateTimeWithTimeZone".to_owned(),
DateTimeCrate::Time => "TimeDateTimeWithTimeZone".to_owned(), DateTimeCrate::Time => "TimeDateTimeWithTimeZone".to_owned(),
}, },
@ -89,8 +89,8 @@ impl Column {
pub fn get_col_type_attrs(&self) -> Option<TokenStream> { pub fn get_col_type_attrs(&self) -> Option<TokenStream> {
let col_type = match &self.col_type { let col_type = match &self.col_type {
ColumnType::Float(Some(l)) => Some(format!("Float(Some({}))", l)), ColumnType::Float => Some("Float".to_owned()),
ColumnType::Double(Some(l)) => Some(format!("Double(Some({}))", l)), ColumnType::Double => Some("Double".to_owned()),
ColumnType::Decimal(Some((p, s))) => Some(format!("Decimal(Some(({}, {})))", p, s)), ColumnType::Decimal(Some((p, s))) => Some(format!("Decimal(Some(({}, {})))", p, s)),
ColumnType::Money(Some((p, s))) => Some(format!("Money(Some({}, {}))", p, s)), ColumnType::Money(Some((p, s))) => Some(format!("Money(Some({}, {}))", p, s)),
ColumnType::Text => Some("Text".to_owned()), ColumnType::Text => Some("Text".to_owned()),
@ -114,26 +114,26 @@ impl Column {
None => quote! { ColumnType::String(None) }, None => quote! { ColumnType::String(None) },
}, },
ColumnType::Text => quote! { ColumnType::Text }, ColumnType::Text => quote! { ColumnType::Text },
ColumnType::TinyInteger(_) => quote! { ColumnType::TinyInteger }, ColumnType::TinyInteger => quote! { ColumnType::TinyInteger },
ColumnType::SmallInteger(_) => quote! { ColumnType::SmallInteger }, ColumnType::SmallInteger => quote! { ColumnType::SmallInteger },
ColumnType::Integer(_) => quote! { ColumnType::Integer }, ColumnType::Integer => quote! { ColumnType::Integer },
ColumnType::BigInteger(_) => quote! { ColumnType::BigInteger }, ColumnType::BigInteger => quote! { ColumnType::BigInteger },
ColumnType::TinyUnsigned(_) => quote! { ColumnType::TinyUnsigned }, ColumnType::TinyUnsigned => quote! { ColumnType::TinyUnsigned },
ColumnType::SmallUnsigned(_) => quote! { ColumnType::SmallUnsigned }, ColumnType::SmallUnsigned => quote! { ColumnType::SmallUnsigned },
ColumnType::Unsigned(_) => quote! { ColumnType::Unsigned }, ColumnType::Unsigned => quote! { ColumnType::Unsigned },
ColumnType::BigUnsigned(_) => quote! { ColumnType::BigUnsigned }, ColumnType::BigUnsigned => quote! { ColumnType::BigUnsigned },
ColumnType::Float(_) => quote! { ColumnType::Float }, ColumnType::Float => quote! { ColumnType::Float },
ColumnType::Double(_) => quote! { ColumnType::Double }, ColumnType::Double => quote! { ColumnType::Double },
ColumnType::Decimal(s) => match s { ColumnType::Decimal(s) => match s {
Some((s1, s2)) => quote! { ColumnType::Decimal(Some((#s1, #s2))) }, Some((s1, s2)) => quote! { ColumnType::Decimal(Some((#s1, #s2))) },
None => quote! { ColumnType::Decimal(None) }, None => quote! { ColumnType::Decimal(None) },
}, },
ColumnType::DateTime(_) => quote! { ColumnType::DateTime }, ColumnType::DateTime => quote! { ColumnType::DateTime },
ColumnType::Timestamp(_) => quote! { ColumnType::Timestamp }, ColumnType::Timestamp => quote! { ColumnType::Timestamp },
ColumnType::TimestampWithTimeZone(_) => { ColumnType::TimestampWithTimeZone => {
quote! { ColumnType::TimestampWithTimeZone } quote! { ColumnType::TimestampWithTimeZone }
} }
ColumnType::Time(_) => quote! { ColumnType::Time }, ColumnType::Time => quote! { ColumnType::Time },
ColumnType::Date => quote! { ColumnType::Date }, ColumnType::Date => quote! { ColumnType::Date },
ColumnType::Binary(BlobSize::Blob(_)) | ColumnType::VarBinary(_) => { ColumnType::Binary(BlobSize::Blob(_)) | ColumnType::VarBinary(_) => {
quote! { ColumnType::Binary } quote! { ColumnType::Binary }
@ -292,24 +292,24 @@ mod tests {
"cake_id", "cake_id",
ColumnType::Custom(SeaRc::new(Alias::new("cus_col"))) ColumnType::Custom(SeaRc::new(Alias::new("cus_col")))
), ),
make_col!("CakeId", ColumnType::TinyInteger(None)), make_col!("CakeId", ColumnType::TinyInteger),
make_col!("CakeId", ColumnType::TinyUnsigned(Some(9))), make_col!("CakeId", ColumnType::TinyUnsigned),
make_col!("CakeId", ColumnType::SmallInteger(None)), make_col!("CakeId", ColumnType::SmallInteger),
make_col!("CakeId", ColumnType::SmallUnsigned(Some(10))), make_col!("CakeId", ColumnType::SmallUnsigned),
make_col!("CakeId", ColumnType::Integer(None)), make_col!("CakeId", ColumnType::Integer),
make_col!("CakeId", ColumnType::Unsigned(Some(11))), make_col!("CakeId", ColumnType::Unsigned),
make_col!("CakeFillingId", ColumnType::BigInteger(None)), make_col!("CakeFillingId", ColumnType::BigInteger),
make_col!("CakeFillingId", ColumnType::BigUnsigned(Some(12))), make_col!("CakeFillingId", ColumnType::BigUnsigned),
make_col!("cake-filling-id", ColumnType::Float(None)), make_col!("cake-filling-id", ColumnType::Float),
make_col!("CAKE_FILLING_ID", ColumnType::Double(None)), make_col!("CAKE_FILLING_ID", ColumnType::Double),
make_col!("CAKE-FILLING-ID", ColumnType::Binary(BlobSize::Blob(None))), make_col!("CAKE-FILLING-ID", ColumnType::Binary(BlobSize::Blob(None))),
make_col!("CAKE-FILLING-ID", ColumnType::VarBinary(10)), make_col!("CAKE-FILLING-ID", ColumnType::VarBinary(10)),
make_col!("CAKE", ColumnType::Boolean), make_col!("CAKE", ColumnType::Boolean),
make_col!("date", ColumnType::Date), make_col!("date", ColumnType::Date),
make_col!("time", ColumnType::Time(None)), make_col!("time", ColumnType::Time),
make_col!("date_time", ColumnType::DateTime(None)), make_col!("date_time", ColumnType::DateTime),
make_col!("timestamp", ColumnType::Timestamp(None)), make_col!("timestamp", ColumnType::Timestamp),
make_col!("timestamp_tz", ColumnType::TimestampWithTimeZone(None)), make_col!("timestamp_tz", ColumnType::TimestampWithTimeZone),
] ]
} }

View File

@ -795,7 +795,7 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: true, auto_increment: true,
not_null: true, not_null: true,
unique: false, unique: false,
@ -832,14 +832,14 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "cake_id".to_owned(), name: "cake_id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "filling_id".to_owned(), name: "filling_id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
@ -884,7 +884,7 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: true, auto_increment: true,
not_null: true, not_null: true,
unique: false, unique: false,
@ -911,7 +911,7 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: true, auto_increment: true,
not_null: true, not_null: true,
unique: false, unique: false,
@ -925,7 +925,7 @@ mod tests {
}, },
Column { Column {
name: "cake_id".to_owned(), name: "cake_id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: false, not_null: false,
unique: false, unique: false,
@ -965,7 +965,7 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: true, auto_increment: true,
not_null: true, not_null: true,
unique: false, unique: false,
@ -979,7 +979,7 @@ mod tests {
}, },
Column { Column {
name: "fruitId".to_owned(), name: "fruitId".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: false, not_null: false,
unique: false, unique: false,
@ -1006,91 +1006,91 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: true, auto_increment: true,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "testing".to_owned(), name: "testing".to_owned(),
col_type: ColumnType::TinyInteger(Some(11)), col_type: ColumnType::TinyInteger,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "rust".to_owned(), name: "rust".to_owned(),
col_type: ColumnType::TinyUnsigned(Some(11)), col_type: ColumnType::TinyUnsigned,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "keywords".to_owned(), name: "keywords".to_owned(),
col_type: ColumnType::SmallInteger(Some(11)), col_type: ColumnType::SmallInteger,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "type".to_owned(), name: "type".to_owned(),
col_type: ColumnType::SmallUnsigned(Some(11)), col_type: ColumnType::SmallUnsigned,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "typeof".to_owned(), name: "typeof".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "crate".to_owned(), name: "crate".to_owned(),
col_type: ColumnType::Unsigned(Some(11)), col_type: ColumnType::Unsigned,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "self".to_owned(), name: "self".to_owned(),
col_type: ColumnType::BigInteger(Some(11)), col_type: ColumnType::BigInteger,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "self_id1".to_owned(), name: "self_id1".to_owned(),
col_type: ColumnType::BigUnsigned(Some(11)), col_type: ColumnType::BigUnsigned,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "self_id2".to_owned(), name: "self_id2".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "fruit_id1".to_owned(), name: "fruit_id1".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "fruit_id2".to_owned(), name: "fruit_id2".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "cake_id".to_owned(), name: "cake_id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
@ -1163,7 +1163,7 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: true, auto_increment: true,
not_null: true, not_null: true,
unique: false, unique: false,
@ -1177,7 +1177,7 @@ mod tests {
}, },
Column { Column {
name: "price".to_owned(), name: "price".to_owned(),
col_type: ColumnType::Float(Some(2)), col_type: ColumnType::Float,
auto_increment: false, auto_increment: false,
not_null: false, not_null: false,
unique: false, unique: false,
@ -1207,7 +1207,7 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: true, auto_increment: true,
not_null: true, not_null: true,
unique: false, unique: false,
@ -1221,7 +1221,7 @@ mod tests {
}, },
Column { Column {
name: "price".to_owned(), name: "price".to_owned(),
col_type: ColumnType::Double(Some(2)), col_type: ColumnType::Double,
auto_increment: false, auto_increment: false,
not_null: false, not_null: false,
unique: false, unique: false,
@ -1251,25 +1251,21 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: true, auto_increment: true,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "integers".to_owned(), name: "integers".to_owned(),
col_type: ColumnType::Array(SeaRc::new(Box::new(ColumnType::Integer( col_type: ColumnType::Array(SeaRc::new(ColumnType::Integer)),
None,
)))),
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "integers_opt".to_owned(), name: "integers_opt".to_owned(),
col_type: ColumnType::Array(SeaRc::new(Box::new(ColumnType::Integer( col_type: ColumnType::Array(SeaRc::new(ColumnType::Integer)),
None,
)))),
auto_increment: false, auto_increment: false,
not_null: false, not_null: false,
unique: false, unique: false,
@ -1286,21 +1282,21 @@ mod tests {
columns: vec![ columns: vec![
Column { Column {
name: "id".to_owned(), name: "id".to_owned(),
col_type: ColumnType::Integer(Some(11)), col_type: ColumnType::Integer,
auto_increment: true, auto_increment: true,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "floats".to_owned(), name: "floats".to_owned(),
col_type: ColumnType::Array(SeaRc::new(Box::new(ColumnType::Float(None)))), col_type: ColumnType::Array(SeaRc::new(ColumnType::Float)),
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,
}, },
Column { Column {
name: "doubles".to_owned(), name: "doubles".to_owned(),
col_type: ColumnType::Array(SeaRc::new(Box::new(ColumnType::Double(None)))), col_type: ColumnType::Array(SeaRc::new(ColumnType::Double)),
auto_increment: false, auto_increment: false,
not_null: true, not_null: true,
unique: false, unique: false,

View File

@ -33,6 +33,7 @@ pub(crate) fn unpack_table_ref(table_ref: &TableRef) -> String {
| TableRef::SchemaTableAlias(_, tbl, _) | TableRef::SchemaTableAlias(_, tbl, _)
| TableRef::DatabaseSchemaTableAlias(_, _, tbl, _) | TableRef::DatabaseSchemaTableAlias(_, _, tbl, _)
| TableRef::SubQuery(_, tbl) | TableRef::SubQuery(_, tbl)
| TableRef::ValuesList(_, tbl) => tbl.to_string(), | TableRef::ValuesList(_, tbl)
| TableRef::FunctionCall(_, tbl) => tbl.to_string(),
} }
} }

View File

@ -9,7 +9,7 @@ pub struct Model {
pub id: i32, pub id: i32,
#[sea_orm(column_type = "Text", nullable)] #[sea_orm(column_type = "Text", nullable)]
pub name: Option<String> , pub name: Option<String> ,
#[sea_orm(column_type = "Double(Some(2))", nullable)] #[sea_orm(column_type = "Double", nullable)]
pub price: Option<f64> , pub price: Option<f64> ,
} }

View File

@ -9,7 +9,7 @@ pub struct Model {
pub id: i32, pub id: i32,
#[sea_orm(column_type = "Text", nullable)] #[sea_orm(column_type = "Text", nullable)]
pub name: Option<String> , pub name: Option<String> ,
#[sea_orm(column_type = "Float(Some(2))", nullable)] #[sea_orm(column_type = "Float", nullable)]
pub price: Option<f32> , pub price: Option<f32> ,
} }

View File

@ -9,7 +9,7 @@ pub struct Model {
pub id: i32, pub id: i32,
#[sea_orm(column_type = "Text", nullable)] #[sea_orm(column_type = "Text", nullable)]
pub name: Option<String> , pub name: Option<String> ,
#[sea_orm(column_type = "Double(Some(2))", nullable)] #[sea_orm(column_type = "Double", nullable)]
pub price: Option<f64> , pub price: Option<f64> ,
} }

View File

@ -9,7 +9,7 @@ pub struct Model {
pub id: i32, pub id: i32,
#[sea_orm(column_type = "Text", nullable)] #[sea_orm(column_type = "Text", nullable)]
pub name: Option<String> , pub name: Option<String> ,
#[sea_orm(column_type = "Float(Some(2))", nullable)] #[sea_orm(column_type = "Float", nullable)]
pub price: Option<f32> , pub price: Option<f32> ,
} }

View File

@ -25,7 +25,7 @@ clap = { version = "3.2", default-features = false, features = ["std", "env", "d
dotenvy = { version = "0.15", default-features = false, optional = true } dotenvy = { version = "0.15", default-features = false, optional = true }
sea-orm = { version = "0.10.3", path = "../", default-features = false, features = ["macros"] } sea-orm = { version = "0.10.3", path = "../", default-features = false, features = ["macros"] }
sea-orm-cli = { version = "0.10.3", path = "../sea-orm-cli", default-features = false, optional = true } sea-orm-cli = { version = "0.10.3", path = "../sea-orm-cli", default-features = false, optional = true }
sea-schema = { version = "0.10.2" } sea-schema = { version = "0.11" }
tracing = { version = "0.1", default-features = false, features = ["log"] } tracing = { version = "0.1", default-features = false, features = ["log"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt"] } tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt"] }

View File

@ -350,15 +350,15 @@ fn query_mysql_foreign_keys(db: &DbConn) -> SelectStatement {
)) ))
.cond_where( .cond_where(
Condition::all() Condition::all()
.add(Expr::expr(get_current_schema(db)).equals( .add(Expr::expr(get_current_schema(db)).equals((
InformationSchema::TableConstraints, InformationSchema::TableConstraints,
InformationSchema::TableSchema, InformationSchema::TableSchema,
)) )))
.add( .add(
Expr::tbl( Expr::col((
InformationSchema::TableConstraints, InformationSchema::TableConstraints,
InformationSchema::ConstraintType, InformationSchema::ConstraintType,
) ))
.eq("FOREIGN KEY"), .eq("FOREIGN KEY"),
), ),
); );
@ -387,16 +387,16 @@ fn query_pg_types(db: &DbConn) -> SelectStatement {
.join( .join(
JoinType::LeftJoin, JoinType::LeftJoin,
PgNamespace::Table, PgNamespace::Table,
Expr::tbl(PgNamespace::Table, PgNamespace::Oid) Expr::col((PgNamespace::Table, PgNamespace::Oid))
.equals(PgType::Table, PgType::Typnamespace), .equals((PgType::Table, PgType::Typnamespace)),
) )
.cond_where( .cond_where(
Condition::all() Condition::all()
.add( .add(
Expr::expr(get_current_schema(db)) Expr::expr(get_current_schema(db))
.equals(PgNamespace::Table, PgNamespace::Nspname), .equals((PgNamespace::Table, PgNamespace::Nspname)),
) )
.add(Expr::tbl(PgType::Table, PgType::Typelem).eq(0)), .add(Expr::col((PgType::Table, PgType::Typelem)).eq(0)),
); );
stmt stmt
} }

View File

@ -412,7 +412,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![ vec![
Transaction::many(vec![ Transaction::many([
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()), Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
Statement::from_sql_and_values( Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
@ -457,7 +457,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![ vec![Transaction::many([
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()), Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
Statement::from_sql_and_values( Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
@ -495,7 +495,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![ vec![Transaction::many([
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()), Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
Statement::from_sql_and_values( Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
@ -553,7 +553,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![ vec![Transaction::many([
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()), Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
Statement::from_sql_and_values( Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,

View File

@ -390,9 +390,7 @@ pub trait EntityTrait: EntityName {
/// ..Default::default() /// ..Default::default()
/// }; /// };
/// ///
/// let insert_result = cake::Entity::insert_many(vec![apple, orange]) /// let insert_result = cake::Entity::insert_many([apple, orange]).exec(&db).await?;
/// .exec(&db)
/// .await?;
/// ///
/// assert_eq!(insert_result.last_insert_id, 28); /// assert_eq!(insert_result.last_insert_id, 28);
/// ///
@ -438,9 +436,7 @@ pub trait EntityTrait: EntityName {
/// ..Default::default() /// ..Default::default()
/// }; /// };
/// ///
/// let insert_result = cake::Entity::insert_many(vec![apple, orange]) /// let insert_result = cake::Entity::insert_many([apple, orange]).exec(&db).await?;
/// .exec(&db)
/// .await?;
/// ///
/// assert_eq!(insert_result.last_insert_id, 28); /// assert_eq!(insert_result.last_insert_id, 28);
/// ///

View File

@ -122,7 +122,7 @@ macro_rules! bind_oper {
where where
V: Into<Value>, V: Into<Value>,
{ {
Expr::tbl(self.entity_name(), *self).$op(v) Expr::col((self.entity_name(), *self)).$op(v)
} }
}; };
} }
@ -135,7 +135,7 @@ macro_rules! bind_oper_with_enum_casting {
V: Into<Value>, V: Into<Value>,
{ {
let expr = cast_text_as_enum(Expr::val(v), self); let expr = cast_text_as_enum(Expr::val(v), self);
Expr::tbl(self.entity_name(), *self).binary(BinOper::$bin_op, expr) Expr::col((self.entity_name(), *self)).binary(BinOper::$bin_op, expr)
} }
}; };
} }
@ -144,7 +144,7 @@ macro_rules! bind_func_no_params {
( $func: ident ) => { ( $func: ident ) => {
/// See also SeaQuery's method with same name. /// See also SeaQuery's method with same name.
fn $func(&self) -> SimpleExpr { fn $func(&self) -> SimpleExpr {
Expr::tbl(self.entity_name(), *self).$func() Expr::col((self.entity_name(), *self)).$func()
} }
}; };
} }
@ -158,7 +158,7 @@ macro_rules! bind_vec_func {
V: Into<Value>, V: Into<Value>,
I: IntoIterator<Item = V>, I: IntoIterator<Item = V>,
{ {
Expr::tbl(self.entity_name(), *self).$func(v) Expr::col((self.entity_name(), *self)).$func(v)
} }
}; };
} }
@ -168,7 +168,7 @@ macro_rules! bind_subquery_func {
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
#[allow(missing_docs)] #[allow(missing_docs)]
fn $func(&self, s: SelectStatement) -> SimpleExpr { fn $func(&self, s: SelectStatement) -> SimpleExpr {
Expr::tbl(self.entity_name(), *self).$func(s) Expr::col((self.entity_name(), *self)).$func(s)
} }
}; };
} }
@ -214,7 +214,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
where where
V: Into<Value>, V: Into<Value>,
{ {
Expr::tbl(self.entity_name(), *self).between(a, b) Expr::col((self.entity_name(), *self)).between(a, b)
} }
/// ``` /// ```
@ -232,7 +232,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
where where
V: Into<Value>, V: Into<Value>,
{ {
Expr::tbl(self.entity_name(), *self).not_between(a, b) Expr::col((self.entity_name(), *self)).not_between(a, b)
} }
/// ``` /// ```
@ -247,7 +247,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
/// ); /// );
/// ``` /// ```
fn like(&self, s: &str) -> SimpleExpr { fn like(&self, s: &str) -> SimpleExpr {
Expr::tbl(self.entity_name(), *self).like(s) Expr::col((self.entity_name(), *self)).like(s)
} }
/// ``` /// ```
@ -262,7 +262,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
/// ); /// );
/// ``` /// ```
fn not_like(&self, s: &str) -> SimpleExpr { fn not_like(&self, s: &str) -> SimpleExpr {
Expr::tbl(self.entity_name(), *self).not_like(s) Expr::col((self.entity_name(), *self)).not_like(s)
} }
/// ``` /// ```
@ -278,7 +278,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
/// ``` /// ```
fn starts_with(&self, s: &str) -> SimpleExpr { fn starts_with(&self, s: &str) -> SimpleExpr {
let pattern = format!("{}%", s); let pattern = format!("{}%", s);
Expr::tbl(self.entity_name(), *self).like(pattern) Expr::col((self.entity_name(), *self)).like(pattern)
} }
/// ``` /// ```
@ -294,7 +294,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
/// ``` /// ```
fn ends_with(&self, s: &str) -> SimpleExpr { fn ends_with(&self, s: &str) -> SimpleExpr {
let pattern = format!("%{}", s); let pattern = format!("%{}", s);
Expr::tbl(self.entity_name(), *self).like(pattern) Expr::col((self.entity_name(), *self)).like(pattern)
} }
/// ``` /// ```
@ -310,7 +310,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
/// ``` /// ```
fn contains(&self, s: &str) -> SimpleExpr { fn contains(&self, s: &str) -> SimpleExpr {
let pattern = format!("%{}%", s); let pattern = format!("%{}%", s);
Expr::tbl(self.entity_name(), *self).like(pattern) Expr::col((self.entity_name(), *self)).like(pattern)
} }
bind_func_no_params!(max); bind_func_no_params!(max);
@ -325,7 +325,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
where where
V: Into<Value>, V: Into<Value>,
{ {
Expr::tbl(self.entity_name(), *self).if_null(v) Expr::col((self.entity_name(), *self)).if_null(v)
} }
bind_vec_func!(is_in); bind_vec_func!(is_in);
@ -410,23 +410,21 @@ impl From<ColumnType> for sea_query::ColumnType {
ColumnType::Char(s) => sea_query::ColumnType::Char(*s), ColumnType::Char(s) => sea_query::ColumnType::Char(*s),
ColumnType::String(s) => sea_query::ColumnType::String(*s), ColumnType::String(s) => sea_query::ColumnType::String(*s),
ColumnType::Text => sea_query::ColumnType::Text, ColumnType::Text => sea_query::ColumnType::Text,
ColumnType::TinyInteger => sea_query::ColumnType::TinyInteger(None), ColumnType::TinyInteger => sea_query::ColumnType::TinyInteger,
ColumnType::SmallInteger => sea_query::ColumnType::SmallInteger(None), ColumnType::SmallInteger => sea_query::ColumnType::SmallInteger,
ColumnType::Integer => sea_query::ColumnType::Integer(None), ColumnType::Integer => sea_query::ColumnType::Integer,
ColumnType::BigInteger => sea_query::ColumnType::BigInteger(None), ColumnType::BigInteger => sea_query::ColumnType::BigInteger,
ColumnType::TinyUnsigned => sea_query::ColumnType::TinyUnsigned(None), ColumnType::TinyUnsigned => sea_query::ColumnType::TinyUnsigned,
ColumnType::SmallUnsigned => sea_query::ColumnType::SmallUnsigned(None), ColumnType::SmallUnsigned => sea_query::ColumnType::SmallUnsigned,
ColumnType::Unsigned => sea_query::ColumnType::Unsigned(None), ColumnType::Unsigned => sea_query::ColumnType::Unsigned,
ColumnType::BigUnsigned => sea_query::ColumnType::BigUnsigned(None), ColumnType::BigUnsigned => sea_query::ColumnType::BigUnsigned,
ColumnType::Float => sea_query::ColumnType::Float(None), ColumnType::Float => sea_query::ColumnType::Float,
ColumnType::Double => sea_query::ColumnType::Double(None), ColumnType::Double => sea_query::ColumnType::Double,
ColumnType::Decimal(s) => sea_query::ColumnType::Decimal(*s), ColumnType::Decimal(s) => sea_query::ColumnType::Decimal(*s),
ColumnType::DateTime => sea_query::ColumnType::DateTime(None), ColumnType::DateTime => sea_query::ColumnType::DateTime,
ColumnType::Timestamp => sea_query::ColumnType::Timestamp(None), ColumnType::Timestamp => sea_query::ColumnType::Timestamp,
ColumnType::TimestampWithTimeZone => { ColumnType::TimestampWithTimeZone => sea_query::ColumnType::TimestampWithTimeZone,
sea_query::ColumnType::TimestampWithTimeZone(None) ColumnType::Time => sea_query::ColumnType::Time,
}
ColumnType::Time => sea_query::ColumnType::Time(None),
ColumnType::Date => sea_query::ColumnType::Date, ColumnType::Date => sea_query::ColumnType::Date,
ColumnType::Binary => { ColumnType::Binary => {
sea_query::ColumnType::Binary(sea_query::BlobSize::Blob(None)) sea_query::ColumnType::Binary(sea_query::BlobSize::Blob(None))
@ -450,7 +448,7 @@ impl From<ColumnType> for sea_query::ColumnType {
}, },
ColumnType::Array(column_type) => { ColumnType::Array(column_type) => {
let column_type = convert_column_type(column_type); let column_type = convert_column_type(column_type);
sea_query::ColumnType::Array(SeaRc::new(Box::new(column_type))) sea_query::ColumnType::Array(SeaRc::new(column_type))
} }
} }
} }
@ -467,23 +465,21 @@ impl From<sea_query::ColumnType> for ColumnType {
sea_query::ColumnType::Char(s) => ColumnType::Char(*s), sea_query::ColumnType::Char(s) => ColumnType::Char(*s),
sea_query::ColumnType::String(s) => ColumnType::String(*s), sea_query::ColumnType::String(s) => ColumnType::String(*s),
sea_query::ColumnType::Text => ColumnType::Text, sea_query::ColumnType::Text => ColumnType::Text,
sea_query::ColumnType::TinyInteger(_) => ColumnType::TinyInteger, sea_query::ColumnType::TinyInteger => ColumnType::TinyInteger,
sea_query::ColumnType::SmallInteger(_) => ColumnType::SmallInteger, sea_query::ColumnType::SmallInteger => ColumnType::SmallInteger,
sea_query::ColumnType::Integer(_) => ColumnType::Integer, sea_query::ColumnType::Integer => ColumnType::Integer,
sea_query::ColumnType::BigInteger(_) => ColumnType::BigInteger, sea_query::ColumnType::BigInteger => ColumnType::BigInteger,
sea_query::ColumnType::TinyUnsigned(_) => ColumnType::TinyUnsigned, sea_query::ColumnType::TinyUnsigned => ColumnType::TinyUnsigned,
sea_query::ColumnType::SmallUnsigned(_) => ColumnType::SmallUnsigned, sea_query::ColumnType::SmallUnsigned => ColumnType::SmallUnsigned,
sea_query::ColumnType::Unsigned(_) => ColumnType::Unsigned, sea_query::ColumnType::Unsigned => ColumnType::Unsigned,
sea_query::ColumnType::BigUnsigned(_) => ColumnType::BigUnsigned, sea_query::ColumnType::BigUnsigned => ColumnType::BigUnsigned,
sea_query::ColumnType::Float(_) => ColumnType::Float, sea_query::ColumnType::Float => ColumnType::Float,
sea_query::ColumnType::Double(_) => ColumnType::Double, sea_query::ColumnType::Double => ColumnType::Double,
sea_query::ColumnType::Decimal(s) => ColumnType::Decimal(*s), sea_query::ColumnType::Decimal(s) => ColumnType::Decimal(*s),
sea_query::ColumnType::DateTime(_) => ColumnType::DateTime, sea_query::ColumnType::DateTime => ColumnType::DateTime,
sea_query::ColumnType::Timestamp(_) => ColumnType::Timestamp, sea_query::ColumnType::Timestamp => ColumnType::Timestamp,
sea_query::ColumnType::TimestampWithTimeZone(_) => { sea_query::ColumnType::TimestampWithTimeZone => ColumnType::TimestampWithTimeZone,
ColumnType::TimestampWithTimeZone sea_query::ColumnType::Time => ColumnType::Time,
}
sea_query::ColumnType::Time(_) => ColumnType::Time,
sea_query::ColumnType::Date => ColumnType::Date, sea_query::ColumnType::Date => ColumnType::Date,
sea_query::ColumnType::Binary(sea_query::BlobSize::Blob(_)) => ColumnType::Binary, sea_query::ColumnType::Binary(sea_query::BlobSize::Blob(_)) => ColumnType::Binary,
sea_query::ColumnType::Binary(sea_query::BlobSize::Tiny) => ColumnType::TinyBinary, sea_query::ColumnType::Binary(sea_query::BlobSize::Tiny) => ColumnType::TinyBinary,

View File

@ -184,7 +184,7 @@ impl RelationDef {
/// .def() /// .def()
/// .rev() /// .rev()
/// .on_condition(|_left, right| { /// .on_condition(|_left, right| {
/// Expr::tbl(right, cake_filling::Column::CakeId) /// Expr::col((right, cake_filling::Column::CakeId))
/// .gt(10i32) /// .gt(10i32)
/// .into_condition() /// .into_condition()
/// }) /// })

View File

@ -48,7 +48,7 @@ where
V: IntoValueTuple, V: IntoValueTuple,
{ {
let condition = self.apply_filter(values, |c, v| { let condition = self.apply_filter(values, |c, v| {
Expr::tbl(SeaRc::clone(&self.table), SeaRc::clone(c)).lt(v) Expr::col((SeaRc::clone(&self.table), SeaRc::clone(c))).lt(v)
}); });
self.query.cond_where(condition); self.query.cond_where(condition);
self self
@ -60,7 +60,7 @@ where
V: IntoValueTuple, V: IntoValueTuple,
{ {
let condition = self.apply_filter(values, |c, v| { let condition = self.apply_filter(values, |c, v| {
Expr::tbl(SeaRc::clone(&self.table), SeaRc::clone(c)).gt(v) Expr::col((SeaRc::clone(&self.table), SeaRc::clone(c))).gt(v)
}); });
self.query.cond_where(condition); self.query.cond_where(condition);
self self
@ -76,20 +76,28 @@ where
(Identity::Binary(c1, c2), ValueTuple::Two(v1, v2)) => Condition::any() (Identity::Binary(c1, c2), ValueTuple::Two(v1, v2)) => Condition::any()
.add( .add(
Condition::all() Condition::all()
.add(Expr::tbl(SeaRc::clone(&self.table), SeaRc::clone(c1)).eq(v1.clone())) .add(
Expr::col((SeaRc::clone(&self.table), SeaRc::clone(c1))).eq(v1.clone()),
)
.add(f(c2, v2)), .add(f(c2, v2)),
) )
.add(f(c1, v1)), .add(f(c1, v1)),
(Identity::Ternary(c1, c2, c3), ValueTuple::Three(v1, v2, v3)) => Condition::any() (Identity::Ternary(c1, c2, c3), ValueTuple::Three(v1, v2, v3)) => Condition::any()
.add( .add(
Condition::all() Condition::all()
.add(Expr::tbl(SeaRc::clone(&self.table), SeaRc::clone(c1)).eq(v1.clone())) .add(
.add(Expr::tbl(SeaRc::clone(&self.table), SeaRc::clone(c2)).eq(v2.clone())) Expr::col((SeaRc::clone(&self.table), SeaRc::clone(c1))).eq(v1.clone()),
)
.add(
Expr::col((SeaRc::clone(&self.table), SeaRc::clone(c2))).eq(v2.clone()),
)
.add(f(c3, v3)), .add(f(c3, v3)),
) )
.add( .add(
Condition::all() Condition::all()
.add(Expr::tbl(SeaRc::clone(&self.table), SeaRc::clone(c1)).eq(v1.clone())) .add(
Expr::col((SeaRc::clone(&self.table), SeaRc::clone(c1))).eq(v1.clone()),
)
.add(f(c2, v2)), .add(f(c2, v2)),
) )
.add(f(c1, v1)), .add(f(c1, v1)),
@ -263,7 +271,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![Statement::from_sql_and_values( vec![Transaction::many([Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
[ [
r#"SELECT "fruit"."id", "fruit"."name", "fruit"."cake_id""#, r#"SELECT "fruit"."id", "fruit"."name", "fruit"."cake_id""#,
@ -323,7 +331,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![Statement::from_sql_and_values( vec![Transaction::many([Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
[ [
r#"SELECT "fruit"."id", "fruit"."name", "fruit"."cake_id""#, r#"SELECT "fruit"."id", "fruit"."name", "fruit"."cake_id""#,
@ -384,7 +392,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![Statement::from_sql_and_values( vec![Transaction::many([Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
[ [
r#"SELECT "fruit"."id", "fruit"."name", "fruit"."cake_id""#, r#"SELECT "fruit"."id", "fruit"."name", "fruit"."cake_id""#,
@ -463,7 +471,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![Statement::from_sql_and_values( vec![Transaction::many([Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
[ [
r#"SELECT "example"."id", "example"."category""#, r#"SELECT "example"."id", "example"."category""#,
@ -501,7 +509,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![Statement::from_sql_and_values( vec![Transaction::many([Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
[ [
r#"SELECT "example"."id", "example"."category""#, r#"SELECT "example"."id", "example"."category""#,
@ -546,7 +554,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![Statement::from_sql_and_values( vec![Transaction::many([Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
[ [
r#"SELECT "example"."id", "example"."category""#, r#"SELECT "example"."id", "example"."category""#,
@ -591,7 +599,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![Statement::from_sql_and_values( vec![Transaction::many([Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
[ [
r#"SELECT "m"."x", "m"."y", "m"."z""#, r#"SELECT "m"."x", "m"."y", "m"."z""#,
@ -630,7 +638,7 @@ mod tests {
assert_eq!( assert_eq!(
db.into_transaction_log(), db.into_transaction_log(),
vec![Transaction::many(vec![Statement::from_sql_and_values( vec![Transaction::many([Statement::from_sql_and_values(
DbBackend::Postgres, DbBackend::Postgres,
[ [
r#"SELECT "m"."x", "m"."y", "m"."z""#, r#"SELECT "m"."x", "m"."y", "m"."z""#,

View File

@ -370,10 +370,10 @@ mod tests {
assert_eq!(paginator.fetch_page(2).await?, pages[2].clone()); assert_eq!(paginator.fetch_page(2).await?, pages[2].clone());
let mut select = SelectStatement::new() let mut select = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -402,10 +402,10 @@ mod tests {
assert_eq!(paginator.fetch_page(2).await?, pages[2].clone()); assert_eq!(paginator.fetch_page(2).await?, pages[2].clone());
let mut select = SelectStatement::new() let mut select = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -436,10 +436,10 @@ mod tests {
assert_eq!(paginator.fetch().await?, pages[2].clone()); assert_eq!(paginator.fetch().await?, pages[2].clone());
let mut select = SelectStatement::new() let mut select = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -472,10 +472,10 @@ mod tests {
assert_eq!(paginator.fetch().await?, pages[2].clone()); assert_eq!(paginator.fetch().await?, pages[2].clone());
let mut select = SelectStatement::new() let mut select = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -503,10 +503,10 @@ mod tests {
assert_eq!(paginator.num_pages().await?, num_pages); assert_eq!(paginator.num_pages().await?, num_pages);
let sub_query = SelectStatement::new() let sub_query = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -537,10 +537,10 @@ mod tests {
assert_eq!(paginator.num_pages().await?, num_pages); assert_eq!(paginator.num_pages().await?, num_pages);
let sub_query = SelectStatement::new() let sub_query = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -607,10 +607,10 @@ mod tests {
assert_eq!(paginator.fetch_and_next().await?, None); assert_eq!(paginator.fetch_and_next().await?, None);
let mut select = SelectStatement::new() let mut select = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -644,10 +644,10 @@ mod tests {
assert_eq!(paginator.fetch_and_next().await?, None); assert_eq!(paginator.fetch_and_next().await?, None);
let mut select = SelectStatement::new() let mut select = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -676,10 +676,10 @@ mod tests {
drop(fruit_stream); drop(fruit_stream);
let mut select = SelectStatement::new() let mut select = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -711,10 +711,10 @@ mod tests {
drop(fruit_stream); drop(fruit_stream);
let mut select = SelectStatement::new() let mut select = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();
@ -752,10 +752,10 @@ mod tests {
drop(fruit_stream); drop(fruit_stream);
let mut select = SelectStatement::new() let mut select = SelectStatement::new()
.exprs(vec![ .exprs([
Expr::tbl(fruit::Entity, fruit::Column::Id), Expr::col((fruit::Entity, fruit::Column::Id)),
Expr::tbl(fruit::Entity, fruit::Column::Name), Expr::col((fruit::Entity, fruit::Column::Name)),
Expr::tbl(fruit::Entity, fruit::Column::CakeId), Expr::col((fruit::Entity, fruit::Column::CakeId)),
]) ])
.from(fruit::Entity) .from(fruit::Entity)
.to_owned(); .to_owned();

View File

@ -182,7 +182,7 @@
//! # }; //! # };
//! //!
//! // insert many //! // insert many
//! Fruit::insert_many(vec![apple, pear]).exec(db).await?; //! Fruit::insert_many([apple, pear]).exec(db).await?;
//! # Ok(()) //! # Ok(())
//! # } //! # }
//! ``` //! ```

View File

@ -215,7 +215,7 @@ pub trait QuerySelect: Sized {
where where
C: IntoSimpleExpr, C: IntoSimpleExpr,
{ {
self.query().add_group_by(vec![col.into_simple_expr()]); self.query().add_group_by([col.into_simple_expr()]);
self self
} }
@ -595,7 +595,7 @@ pub trait QueryFilter: Sized {
{ {
for key in <M::Entity as EntityTrait>::PrimaryKey::iter() { for key in <M::Entity as EntityTrait>::PrimaryKey::iter() {
let col = key.into_column(); let col = key.into_column();
let expr = Expr::tbl(Alias::new(tbl_alias), col).eq(model.get(col)); let expr = Expr::col((Alias::new(tbl_alias), col)).eq(model.get(col));
self = self.filter(expr); self = self.filter(expr);
} }
self self
@ -636,18 +636,18 @@ pub(crate) fn join_tbl_on_condition(
) -> SimpleExpr { ) -> SimpleExpr {
match (owner_keys, foreign_keys) { match (owner_keys, foreign_keys) {
(Identity::Unary(o1), Identity::Unary(f1)) => { (Identity::Unary(o1), Identity::Unary(f1)) => {
Expr::tbl(SeaRc::clone(&from_tbl), o1).equals(SeaRc::clone(&to_tbl), f1) Expr::col((SeaRc::clone(&from_tbl), o1)).equals((SeaRc::clone(&to_tbl), f1))
} }
(Identity::Binary(o1, o2), Identity::Binary(f1, f2)) => { (Identity::Binary(o1, o2), Identity::Binary(f1, f2)) => {
Expr::tbl(SeaRc::clone(&from_tbl), o1) Expr::col((SeaRc::clone(&from_tbl), o1))
.equals(SeaRc::clone(&to_tbl), f1) .equals((SeaRc::clone(&to_tbl), f1))
.and(Expr::tbl(SeaRc::clone(&from_tbl), o2).equals(SeaRc::clone(&to_tbl), f2)) .and(Expr::col((SeaRc::clone(&from_tbl), o2)).equals((SeaRc::clone(&to_tbl), f2)))
} }
(Identity::Ternary(o1, o2, o3), Identity::Ternary(f1, f2, f3)) => { (Identity::Ternary(o1, o2, o3), Identity::Ternary(f1, f2, f3)) => {
Expr::tbl(SeaRc::clone(&from_tbl), o1) Expr::col((SeaRc::clone(&from_tbl), o1))
.equals(SeaRc::clone(&to_tbl), f1) .equals((SeaRc::clone(&to_tbl), f1))
.and(Expr::tbl(SeaRc::clone(&from_tbl), o2).equals(SeaRc::clone(&to_tbl), f2)) .and(Expr::col((SeaRc::clone(&from_tbl), o2)).equals((SeaRc::clone(&to_tbl), f2)))
.and(Expr::tbl(SeaRc::clone(&from_tbl), o3).equals(SeaRc::clone(&to_tbl), f3)) .and(Expr::col((SeaRc::clone(&from_tbl), o3)).equals((SeaRc::clone(&to_tbl), f3)))
} }
_ => panic!("Owner key and foreign key mismatch"), _ => panic!("Owner key and foreign key mismatch"),
} }
@ -662,7 +662,8 @@ pub(crate) fn unpack_table_ref(table_ref: &TableRef) -> DynIden {
| TableRef::SchemaTableAlias(_, tbl, _) | TableRef::SchemaTableAlias(_, tbl, _)
| TableRef::DatabaseSchemaTableAlias(_, _, tbl, _) | TableRef::DatabaseSchemaTableAlias(_, _, tbl, _)
| TableRef::SubQuery(_, tbl) | TableRef::SubQuery(_, tbl)
| TableRef::ValuesList(_, tbl) => SeaRc::clone(tbl), | TableRef::ValuesList(_, tbl)
| TableRef::FunctionCall(_, tbl) => SeaRc::clone(tbl),
} }
} }
@ -675,7 +676,8 @@ pub(crate) fn unpack_table_alias(table_ref: &TableRef) -> Option<DynIden> {
| TableRef::ValuesList(_, _) => None, | TableRef::ValuesList(_, _) => None,
TableRef::TableAlias(_, alias) TableRef::TableAlias(_, alias)
| TableRef::SchemaTableAlias(_, _, alias) | TableRef::SchemaTableAlias(_, _, alias)
| TableRef::DatabaseSchemaTableAlias(_, _, _, alias) => Some(SeaRc::clone(alias)), | TableRef::DatabaseSchemaTableAlias(_, _, _, alias)
| TableRef::FunctionCall(_, alias) => Some(SeaRc::clone(alias)),
} }
} }

View File

@ -85,7 +85,7 @@ where
/// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend}; /// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
/// ///
/// assert_eq!( /// assert_eq!(
/// Insert::many(vec![ /// Insert::many([
/// cake::Model { /// cake::Model {
/// id: 1, /// id: 1,
/// name: "Apple Pie".to_owned(), /// name: "Apple Pie".to_owned(),
@ -275,7 +275,7 @@ mod tests {
fn insert_4() { fn insert_4() {
assert_eq!( assert_eq!(
Insert::<cake::ActiveModel>::new() Insert::<cake::ActiveModel>::new()
.add_many(vec![ .add_many([
cake::Model { cake::Model {
id: 1, id: 1,
name: "Apple Pie".to_owned(), name: "Apple Pie".to_owned(),
@ -304,7 +304,7 @@ mod tests {
}; };
assert_eq!( assert_eq!(
Insert::<cake::ActiveModel>::new() Insert::<cake::ActiveModel>::new()
.add_many(vec![apple, orange]) .add_many([apple, orange])
.build(DbBackend::Postgres) .build(DbBackend::Postgres)
.to_string(), .to_string(),
r#"INSERT INTO "cake" ("id", "name") VALUES (NULL, 'Apple'), (2, 'Orange')"#, r#"INSERT INTO "cake" ("id", "name") VALUES (NULL, 'Apple'), (2, 'Orange')"#,

View File

@ -95,10 +95,10 @@ where
let mut select_two = SelectTwo::new_without_prepare(slf.query); let mut select_two = SelectTwo::new_without_prepare(slf.query);
for col in <T::Column as Iterable>::iter() { for col in <T::Column as Iterable>::iter() {
let alias = format!("{}{}", SelectB.as_str(), col.as_str()); let alias = format!("{}{}", SelectB.as_str(), col.as_str());
let expr = Expr::tbl( let expr = Expr::col((
Alias::new(&format!("r{}", l.link().len() - 1)).into_iden(), Alias::new(&format!("r{}", l.link().len() - 1)).into_iden(),
col.into_iden(), col.into_iden(),
); ));
select_two.query().expr(SelectExpr { select_two.query().expr(SelectExpr {
expr: cast_enum_as_text(expr, &col), expr: cast_enum_as_text(expr, &col),
alias: Some(SeaRc::new(Alias::new(&alias))), alias: Some(SeaRc::new(Alias::new(&alias))),
@ -471,7 +471,7 @@ mod tests {
.def() .def()
.rev() .rev()
.on_condition(|_left, right| { .on_condition(|_left, right| {
Expr::tbl(right, cake_filling::Column::CakeId) Expr::col((right, cake_filling::Column::CakeId))
.gt(10) .gt(10)
.into_condition() .into_condition()
}) })
@ -481,7 +481,7 @@ mod tests {
cake_filling::Relation::Filling cake_filling::Relation::Filling
.def() .def()
.on_condition(|_left, right| { .on_condition(|_left, right| {
Expr::tbl(right, filling::Column::Name) Expr::col((right, filling::Column::Name))
.like("%lemon%") .like("%lemon%")
.into_condition() .into_condition()
}) })
@ -505,7 +505,7 @@ mod tests {
assert_eq!( assert_eq!(
cake::Entity::find() cake::Entity::find()
.column_as( .column_as(
Expr::tbl(Alias::new("fruit_alias"), fruit::Column::Name).into_simple_expr(), Expr::col((Alias::new("fruit_alias"), fruit::Column::Name)),
"fruit_name" "fruit_name"
) )
.join_as( .join_as(
@ -513,7 +513,7 @@ mod tests {
cake::Relation::Fruit cake::Relation::Fruit
.def() .def()
.on_condition(|_left, right| { .on_condition(|_left, right| {
Expr::tbl(right, fruit::Column::Name) Expr::col((right, fruit::Column::Name))
.like("%tropical%") .like("%tropical%")
.into_condition() .into_condition()
}), }),
@ -534,7 +534,7 @@ mod tests {
assert_eq!( assert_eq!(
cake::Entity::find() cake::Entity::find()
.column_as( .column_as(
Expr::tbl(Alias::new("cake_filling_alias"), cake_filling::Column::CakeId).into_simple_expr(), Expr::col((Alias::new("cake_filling_alias"), cake_filling::Column::CakeId)),
"cake_filling_cake_id" "cake_filling_cake_id"
) )
.join(JoinType::LeftJoin, cake::Relation::TropicalFruit.def()) .join(JoinType::LeftJoin, cake::Relation::TropicalFruit.def())
@ -543,7 +543,7 @@ mod tests {
cake_filling::Relation::Cake cake_filling::Relation::Cake
.def() .def()
.on_condition(|left, _right| { .on_condition(|left, _right| {
Expr::tbl(left, cake_filling::Column::CakeId) Expr::col((left, cake_filling::Column::CakeId))
.gt(10) .gt(10)
.into_condition() .into_condition()
}), }),

View File

@ -5,7 +5,7 @@ use crate::{
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::{IntoColumnRef, SelectStatement, SimpleExpr}; use sea_query::{Expr, IntoColumnRef, SelectStatement, SimpleExpr};
/// Defines a structure to perform select operations /// Defines a structure to perform select operations
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -97,6 +97,12 @@ where
} }
} }
impl IntoSimpleExpr for Expr {
fn into_simple_expr(self) -> SimpleExpr {
self.into()
}
}
impl IntoSimpleExpr for SimpleExpr { impl IntoSimpleExpr for SimpleExpr {
fn into_simple_expr(self) -> SimpleExpr { fn into_simple_expr(self) -> SimpleExpr {
self self

View File

@ -47,7 +47,7 @@ impl Linked for CheeseCakeToFillingVendor {
super::cake_filling::Relation::Cake super::cake_filling::Relation::Cake
.def() .def()
.on_condition(|left, _right| { .on_condition(|left, _right| {
Expr::tbl(left, super::cake::Column::Name) Expr::col((left, super::cake::Column::Name))
.like("%cheese%") .like("%cheese%")
.into_condition() .into_condition()
}) })
@ -71,7 +71,7 @@ impl Linked for JoinWithoutReverse {
super::cake_filling::Relation::Cake super::cake_filling::Relation::Cake
.def() .def()
.on_condition(|left, _right| { .on_condition(|left, _right| {
Expr::tbl(left, super::cake::Column::Name) Expr::col((left, super::cake::Column::Name))
.like("%cheese%") .like("%cheese%")
.into_condition() .into_condition()
}), }),

View File

@ -65,6 +65,6 @@ impl ValueType for Events {
} }
fn column_type() -> ColumnType { fn column_type() -> ColumnType {
ColumnType::Array(SeaRc::new(Box::new(ColumnType::String(None)))) ColumnType::Array(SeaRc::new(ColumnType::String(None)))
} }
} }

View File

@ -27,7 +27,7 @@ pub async fn create_tables(db: &DatabaseConnection) -> Result<(), DbErr> {
let schema = Schema::new(db_backend); let schema = Schema::new(db_backend);
let enum_create_stmt = Type::create() let enum_create_stmt = Type::create()
.as_enum(Alias::new("tea")) .as_enum(Alias::new("tea"))
.values(vec![Alias::new("EverydayTea"), Alias::new("BreakfastTea")]) .values([Alias::new("EverydayTea"), Alias::new("BreakfastTea")])
.to_owned(); .to_owned();
assert_eq!( assert_eq!(
db_backend.build(&enum_create_stmt), db_backend.build(&enum_create_stmt),
@ -345,13 +345,10 @@ pub async fn create_collection_table(db: &DbConn) -> Result<ExecResult, DbErr> {
) )
.col( .col(
ColumnDef::new(collection::Column::Integers) ColumnDef::new(collection::Column::Integers)
.array(sea_query::ColumnType::Integer(None)) .array(sea_query::ColumnType::Integer)
.not_null(), .not_null(),
) )
.col( .col(ColumnDef::new(collection::Column::IntegersOpt).array(sea_query::ColumnType::Integer))
ColumnDef::new(collection::Column::IntegersOpt)
.array(sea_query::ColumnType::Integer(None)),
)
.col( .col(
ColumnDef::new(collection::Column::Teas) ColumnDef::new(collection::Column::Teas)
.array(sea_query::ColumnType::Enum { .array(sea_query::ColumnType::Enum {
@ -374,13 +371,10 @@ pub async fn create_collection_table(db: &DbConn) -> Result<ExecResult, DbErr> {
) )
.col( .col(
ColumnDef::new(collection::Column::Colors) ColumnDef::new(collection::Column::Colors)
.array(sea_query::ColumnType::Integer(None)) .array(sea_query::ColumnType::Integer)
.not_null(), .not_null(),
) )
.col( .col(ColumnDef::new(collection::Column::ColorsOpt).array(sea_query::ColumnType::Integer))
ColumnDef::new(collection::Column::ColorsOpt)
.array(sea_query::ColumnType::Integer(None)),
)
.to_owned(); .to_owned();
create_table(db, &stmt, Collection).await create_table(db, &stmt, Collection).await

View File

@ -64,7 +64,7 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> {
assert_eq!( assert_eq!(
metadata, metadata,
vec![ [
find_res.0.clone().unwrap(), find_res.0.clone().unwrap(),
find_res.1.clone().unwrap(), find_res.1.clone().unwrap(),
find_res.2.clone().unwrap(), find_res.2.clone().unwrap(),

View File

@ -660,15 +660,15 @@ pub async fn linked() -> Result<(), DbErr> {
.select_only() .select_only()
.column_as(baker::Column::Name, (SelectA, baker::Column::Name)) .column_as(baker::Column::Name, (SelectA, baker::Column::Name))
.column_as( .column_as(
Expr::tbl(Alias::new("r4"), customer::Column::Name).into_simple_expr(), Expr::col((Alias::new("r4"), customer::Column::Name)),
(SelectB, customer::Column::Name), (SelectB, customer::Column::Name),
) )
.group_by(baker::Column::Id) .group_by(baker::Column::Id)
.group_by(Expr::tbl(Alias::new("r4"), customer::Column::Id).into_simple_expr()) .group_by(Expr::col((Alias::new("r4"), customer::Column::Id)))
.group_by(baker::Column::Name) .group_by(baker::Column::Name)
.group_by(Expr::tbl(Alias::new("r4"), customer::Column::Name).into_simple_expr()) .group_by(Expr::col((Alias::new("r4"), customer::Column::Name)))
.order_by_asc(baker::Column::Id) .order_by_asc(baker::Column::Id)
.order_by_asc(Expr::tbl(Alias::new("r4"), customer::Column::Id).into_simple_expr()) .order_by_asc(Expr::col((Alias::new("r4"), customer::Column::Id)))
.into_model() .into_model()
.all(&ctx.db) .all(&ctx.db)
.await?; .await?;

View File

@ -20,20 +20,19 @@ async fn main() -> Result<(), DbErr> {
let mut insert = Query::insert(); let mut insert = Query::insert();
insert insert
.into_table(Entity) .into_table(Entity)
.columns(vec![Column::Name, Column::ProfitMargin]) .columns([Column::Name, Column::ProfitMargin])
.values_panic(vec!["Bakery Shop".into(), 0.5.into()]); .values_panic(["Bakery Shop".into(), 0.5.into()]);
let mut update = Query::update(); let mut update = Query::update();
update update
.table(Entity) .table(Entity)
.values(vec![ .values([
(Column::Name, "Bakery Shop".into()), (Column::Name, "Bakery Shop".into()),
(Column::ProfitMargin, 0.5.into()), (Column::ProfitMargin, 0.5.into()),
]) ])
.and_where(Column::Id.eq(1)); .and_where(Column::Id.eq(1));
let returning = let returning = Query::returning().columns([Column::Id, Column::Name, Column::ProfitMargin]);
Query::returning().columns(vec![Column::Id, Column::Name, Column::ProfitMargin]);
create_tables(db).await?; create_tables(db).await?;