Skip to content

Commit

Permalink
Cont. Upgrade to SeaQuery 0.28.0 (#1366)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
billy1624 and ikrivosheev authored Jan 5, 2023
1 parent 8781c03 commit e246d3f
Show file tree
Hide file tree
Showing 32 changed files with 265 additions and 267 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ tracing = { version = "0.1", default-features = false, features = ["attributes",
rust_decimal = { version = "1", 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-query = { version = "0.27.2", features = ["thread-safe"] }
sea-query-binder = { version = "0.2.2", default-features = false, optional = true }
sea-query = { version = "0.28", features = ["thread-safe"] }
sea-query-binder = { version = "0.3", default-features = false, optional = true }
sea-strum = { version = "0.23", default-features = false, features = ["derive", "sea-orm"] }
serde = { version = "1.0", default-features = false }
serde_json = { version = "1.0", default-features = false, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ let pear = fruit::ActiveModel {
let pear = pear.insert(db).await?;

// insert many
Fruit::insert_many(vec![apple, pear]).exec(db).await?;
Fruit::insert_many([apple, pear]).exec(db).await?;
```
### Update
```rust
Expand Down
4 changes: 2 additions & 2 deletions issues/319/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub struct Model {
pub updated_at: DateTimeWithTimeZone,
pub name: String,
#[sea_orm(column_type = "Text", nullable)]
pub description: Option<String>,
pub tag_ids: Vec<u8>,
pub description: Option<String> ,
pub tag_ids: Vec<u8> ,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ clap = { version = "3.2", default-features = false, features = ["std", "env", "d
dotenvy = { version = "0.15", default-features = false, 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-schema = { version = "0.10.2" }
sea-schema = { version = "0.11" }
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 = { version = "0.1", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ name = "sea_orm_codegen"
path = "src/lib.rs"

[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 }
quote = { version = "1", default-features = false }
heck = { version = "0.3", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions sea-orm-codegen/src/entity/base_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ impl Entity {
}

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 {
ColumnType::Float(_) | ColumnType::Double(_) => true,
ColumnType::Float | ColumnType::Double => true,
ColumnType::Array(col_type) => is_floats(col_type),
_ => false,
}
Expand Down Expand Up @@ -199,7 +199,7 @@ mod tests {
columns: vec![
Column {
name: "id".to_owned(),
col_type: ColumnType::Integer(None),
col_type: ColumnType::Integer,
auto_increment: false,
not_null: false,
unique: false,
Expand Down
88 changes: 44 additions & 44 deletions sea-orm-codegen/src/entity/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,35 @@ impl Column {
| ColumnType::String(_)
| ColumnType::Text
| ColumnType::Custom(_) => "String".to_owned(),
ColumnType::TinyInteger(_) => "i8".to_owned(),
ColumnType::SmallInteger(_) => "i16".to_owned(),
ColumnType::Integer(_) => "i32".to_owned(),
ColumnType::BigInteger(_) => "i64".to_owned(),
ColumnType::TinyUnsigned(_) => "u8".to_owned(),
ColumnType::SmallUnsigned(_) => "u16".to_owned(),
ColumnType::Unsigned(_) => "u32".to_owned(),
ColumnType::BigUnsigned(_) => "u64".to_owned(),
ColumnType::Float(_) => "f32".to_owned(),
ColumnType::Double(_) => "f64".to_owned(),
ColumnType::TinyInteger => "i8".to_owned(),
ColumnType::SmallInteger => "i16".to_owned(),
ColumnType::Integer => "i32".to_owned(),
ColumnType::BigInteger => "i64".to_owned(),
ColumnType::TinyUnsigned => "u8".to_owned(),
ColumnType::SmallUnsigned => "u16".to_owned(),
ColumnType::Unsigned => "u32".to_owned(),
ColumnType::BigUnsigned => "u64".to_owned(),
ColumnType::Float => "f32".to_owned(),
ColumnType::Double => "f64".to_owned(),
ColumnType::Json | ColumnType::JsonBinary => "Json".to_owned(),
ColumnType::Date => match date_time_crate {
DateTimeCrate::Chrono => "Date".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::Time => "TimeTime".to_owned(),
},
ColumnType::DateTime(_) => match date_time_crate {
ColumnType::DateTime => match date_time_crate {
DateTimeCrate::Chrono => "DateTime".to_owned(),
DateTimeCrate::Time => "TimeDateTime".to_owned(),
},
ColumnType::Timestamp(_) => match date_time_crate {
ColumnType::Timestamp => match date_time_crate {
DateTimeCrate::Chrono => "DateTimeUtc".to_owned(),
// ColumnType::Timpestamp(_) => time::PrimitiveDateTime: https://docs.rs/sqlx/0.3.5/sqlx/postgres/types/index.html#time
DateTimeCrate::Time => "TimeDateTime".to_owned(),
},
ColumnType::TimestampWithTimeZone(_) => match date_time_crate {
ColumnType::TimestampWithTimeZone => match date_time_crate {
DateTimeCrate::Chrono => "DateTimeWithTimeZone".to_owned(),
DateTimeCrate::Time => "TimeDateTimeWithTimeZone".to_owned(),
},
Expand All @@ -89,8 +89,8 @@ impl Column {

pub fn get_col_type_attrs(&self) -> Option<TokenStream> {
let col_type = match &self.col_type {
ColumnType::Float(Some(l)) => Some(format!("Float(Some({}))", l)),
ColumnType::Double(Some(l)) => Some(format!("Double(Some({}))", l)),
ColumnType::Float => Some("Float".to_owned()),
ColumnType::Double => Some("Double".to_owned()),
ColumnType::Decimal(Some((p, s))) => Some(format!("Decimal(Some(({}, {})))", p, s)),
ColumnType::Money(Some((p, s))) => Some(format!("Money(Some({}, {}))", p, s)),
ColumnType::Text => Some("Text".to_owned()),
Expand All @@ -114,26 +114,26 @@ impl Column {
None => quote! { ColumnType::String(None) },
},
ColumnType::Text => quote! { ColumnType::Text },
ColumnType::TinyInteger(_) => quote! { ColumnType::TinyInteger },
ColumnType::SmallInteger(_) => quote! { ColumnType::SmallInteger },
ColumnType::Integer(_) => quote! { ColumnType::Integer },
ColumnType::BigInteger(_) => quote! { ColumnType::BigInteger },
ColumnType::TinyUnsigned(_) => quote! { ColumnType::TinyUnsigned },
ColumnType::SmallUnsigned(_) => quote! { ColumnType::SmallUnsigned },
ColumnType::Unsigned(_) => quote! { ColumnType::Unsigned },
ColumnType::BigUnsigned(_) => quote! { ColumnType::BigUnsigned },
ColumnType::Float(_) => quote! { ColumnType::Float },
ColumnType::Double(_) => quote! { ColumnType::Double },
ColumnType::TinyInteger => quote! { ColumnType::TinyInteger },
ColumnType::SmallInteger => quote! { ColumnType::SmallInteger },
ColumnType::Integer => quote! { ColumnType::Integer },
ColumnType::BigInteger => quote! { ColumnType::BigInteger },
ColumnType::TinyUnsigned => quote! { ColumnType::TinyUnsigned },
ColumnType::SmallUnsigned => quote! { ColumnType::SmallUnsigned },
ColumnType::Unsigned => quote! { ColumnType::Unsigned },
ColumnType::BigUnsigned => quote! { ColumnType::BigUnsigned },
ColumnType::Float => quote! { ColumnType::Float },
ColumnType::Double => quote! { ColumnType::Double },
ColumnType::Decimal(s) => match s {
Some((s1, s2)) => quote! { ColumnType::Decimal(Some((#s1, #s2))) },
None => quote! { ColumnType::Decimal(None) },
},
ColumnType::DateTime(_) => quote! { ColumnType::DateTime },
ColumnType::Timestamp(_) => quote! { ColumnType::Timestamp },
ColumnType::TimestampWithTimeZone(_) => {
ColumnType::DateTime => quote! { ColumnType::DateTime },
ColumnType::Timestamp => quote! { ColumnType::Timestamp },
ColumnType::TimestampWithTimeZone => {
quote! { ColumnType::TimestampWithTimeZone }
}
ColumnType::Time(_) => quote! { ColumnType::Time },
ColumnType::Time => quote! { ColumnType::Time },
ColumnType::Date => quote! { ColumnType::Date },
ColumnType::Binary(BlobSize::Blob(_)) | ColumnType::VarBinary(_) => {
quote! { ColumnType::Binary }
Expand Down Expand Up @@ -292,24 +292,24 @@ mod tests {
"cake_id",
ColumnType::Custom(SeaRc::new(Alias::new("cus_col")))
),
make_col!("CakeId", ColumnType::TinyInteger(None)),
make_col!("CakeId", ColumnType::TinyUnsigned(Some(9))),
make_col!("CakeId", ColumnType::SmallInteger(None)),
make_col!("CakeId", ColumnType::SmallUnsigned(Some(10))),
make_col!("CakeId", ColumnType::Integer(None)),
make_col!("CakeId", ColumnType::Unsigned(Some(11))),
make_col!("CakeFillingId", ColumnType::BigInteger(None)),
make_col!("CakeFillingId", ColumnType::BigUnsigned(Some(12))),
make_col!("cake-filling-id", ColumnType::Float(None)),
make_col!("CAKE_FILLING_ID", ColumnType::Double(None)),
make_col!("CakeId", ColumnType::TinyInteger),
make_col!("CakeId", ColumnType::TinyUnsigned),
make_col!("CakeId", ColumnType::SmallInteger),
make_col!("CakeId", ColumnType::SmallUnsigned),
make_col!("CakeId", ColumnType::Integer),
make_col!("CakeId", ColumnType::Unsigned),
make_col!("CakeFillingId", ColumnType::BigInteger),
make_col!("CakeFillingId", ColumnType::BigUnsigned),
make_col!("cake-filling-id", ColumnType::Float),
make_col!("CAKE_FILLING_ID", ColumnType::Double),
make_col!("CAKE-FILLING-ID", ColumnType::Binary(BlobSize::Blob(None))),
make_col!("CAKE-FILLING-ID", ColumnType::VarBinary(10)),
make_col!("CAKE", ColumnType::Boolean),
make_col!("date", ColumnType::Date),
make_col!("time", ColumnType::Time(None)),
make_col!("date_time", ColumnType::DateTime(None)),
make_col!("timestamp", ColumnType::Timestamp(None)),
make_col!("timestamp_tz", ColumnType::TimestampWithTimeZone(None)),
make_col!("time", ColumnType::Time),
make_col!("date_time", ColumnType::DateTime),
make_col!("timestamp", ColumnType::Timestamp),
make_col!("timestamp_tz", ColumnType::TimestampWithTimeZone),
]
}

Expand Down
Loading

0 comments on commit e246d3f

Please sign in to comment.