Skip to content

Commit

Permalink
Upgrade sea-query to 0.29 (#1562)
Browse files Browse the repository at this point in the history
* Upgrade `sea-query` to 0.29

* clippy

* More upgrades

* fixup
  • Loading branch information
billy1624 committed Mar 22, 2023
1 parent 83a6071 commit 737a894
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 45 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.12.0", path = "sea-orm-macros", default-features = false, features = ["strum"] }
sea-query = { version = "0.28.3", features = ["thread-safe"] }
sea-query-binder = { version = "0.3", default-features = false, optional = true }
sea-query = { version = "0.29.0-rc.1", features = ["thread-safe"] }
sea-query-binder = { version = "0.4.0-rc.1", default-features = false, optional = true }
strum = { version = "0.24", default-features = false }
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 sea-orm-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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.12.0", path = "../sea-orm-codegen", default-features = false, optional = true }
sea-schema = { version = "0.11" }
sea-schema = { version = "0.12.0-rc.1" }
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.28.3", default-features = false, features = ["thread-safe"] }
sea-query = { version = "0.29.0-rc.1", default-features = false, features = ["thread-safe"] }
syn = { version = "1", default-features = false, features = ["parsing", "proc-macro", "derive", "printing"] }
quote = { version = "1", default-features = false }
heck = { version = "0.4", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions sea-orm-macros/src/derives/entity_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec<Attribute>) -> syn::Res

if let Some(select_as) = select_as {
columns_select_as.push(quote! {
Self::#field_name => expr.cast_as(sea_orm::sea_query::Alias::new(&#select_as))
Self::#field_name => expr.cast_as(sea_orm::sea_query::Alias::new(#select_as))
});
}
if let Some(save_as) = save_as {
columns_save_as.push(quote! {
Self::#field_name => val.cast_as(sea_orm::sea_query::Alias::new(&#save_as))
Self::#field_name => val.cast_as(sea_orm::sea_query::Alias::new(#save_as))
});
}

Expand Down
2 changes: 1 addition & 1 deletion sea-orm-migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ clap = { version = "3.2", default-features = false, features = ["std", "env", "d
dotenvy = { version = "0.15", default-features = false, optional = true }
sea-orm = { version = "0.12.0", path = "../", default-features = false, features = ["macros"] }
sea-orm-cli = { version = "0.12.0", path = "../sea-orm-cli", default-features = false, optional = true }
sea-schema = { version = "0.11" }
sea-schema = { version = "0.12.0-rc.1" }
tracing = { version = "0.1", default-features = false, features = ["log"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt"] }
futures = { version = "0.3", default-features = false, features = ["std"] }
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-migration/src/migrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ where
let type_name: String = row.try_get("", "typname")?;
info!("Dropping type '{}'", type_name);
let mut stmt = Type::drop();
stmt.name(Alias::new(&type_name as &str));
stmt.name(Alias::new(&type_name));
db.execute(db_backend.build(&stmt)).await?;
info!("Type '{}' has been dropped", type_name);
}
Expand Down
31 changes: 7 additions & 24 deletions src/entity/active_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,31 +155,14 @@ pub trait ActiveModelTrait: Clone + Debug {
let s3 = next!();
Some(ValueTuple::Three(s1, s2, s3))
}
4 => {
let s1 = next!();
let s2 = next!();
let s3 = next!();
let s4 = next!();
Some(ValueTuple::Four(s1, s2, s3, s4))
}
5 => {
let s1 = next!();
let s2 = next!();
let s3 = next!();
let s4 = next!();
let s5 = next!();
Some(ValueTuple::Five(s1, s2, s3, s4, s5))
}
6 => {
let s1 = next!();
let s2 = next!();
let s3 = next!();
let s4 = next!();
let s5 = next!();
let s6 = next!();
Some(ValueTuple::Six(s1, s2, s3, s4, s5, s6))
len => {
let mut vec = Vec::with_capacity(len);
for _ in 0..len {
let s = next!();
vec.push(s);
}
Some(ValueTuple::Many(vec))
}
_ => panic!("The arity cannot be larger than 6"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/entity/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {
cast_enum_as(val, self, |col, enum_name, col_type| {
let type_name = match col_type {
ColumnType::Array(_) => {
Alias::new(&format!("{}[]", enum_name.to_string())).into_iden()
Alias::new(format!("{}[]", enum_name.to_string())).into_iden()
}
_ => enum_name,
};
Expand Down
4 changes: 2 additions & 2 deletions src/entity/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ pub trait Linked {
fn find_linked(&self) -> Select<Self::ToEntity> {
let mut select = Select::new();
for (i, mut rel) in self.link().into_iter().rev().enumerate() {
let from_tbl = Alias::new(&format!("r{i}")).into_iden();
let from_tbl = Alias::new(format!("r{i}")).into_iden();
let to_tbl = if i > 0 {
Alias::new(&format!("r{}", i - 1)).into_iden()
Alias::new(format!("r{}", i - 1)).into_iden()
} else {
unpack_table_ref(&rel.to_tbl)
};
Expand Down
4 changes: 2 additions & 2 deletions src/executor/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{
Select, SelectModel, SelectorTrait,
};
use sea_query::{
Condition, DynIden, Expr, IntoValueTuple, Order, OrderedStatement, SeaRc, SelectStatement,
SimpleExpr, Value, ValueTuple,
Condition, DynIden, Expr, IntoValueTuple, Order, SeaRc, SelectStatement, SimpleExpr, Value,
ValueTuple,
};
use std::marker::PhantomData;

Expand Down
2 changes: 1 addition & 1 deletion src/executor/paginator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ where
type Selector = S;
fn paginate(self, db: &'db C, page_size: u64) -> Paginator<'db, C, S> {
assert!(page_size != 0, "page_size should not be zero");
let sql = &self.stmt.sql.trim()[6..].trim();
let sql = self.stmt.sql.trim()[6..].trim();
let mut query = SelectStatement::new();
query.expr(if let Some(values) = self.stmt.values {
Expr::cust_with_values(sql, values.0)
Expand Down
6 changes: 3 additions & 3 deletions src/query/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
match &sel.alias {
Some(alias) => {
let alias = format!("{}{}", pre, alias.to_string().as_str());
sel.alias = Some(SeaRc::new(Alias::new(&alias)));
sel.alias = Some(SeaRc::new(Alias::new(alias)));
}
None => {
let col = match &sel.expr {
Expand Down Expand Up @@ -65,7 +65,7 @@ where
_ => panic!("cannot apply alias for expr other than Column or AsEnum"),
};
let alias = format!("{}{}", pre, col.to_string().as_str());
sel.alias = Some(SeaRc::new(Alias::new(&alias)));
sel.alias = Some(SeaRc::new(Alias::new(alias)));
}
};
});
Expand Down Expand Up @@ -149,7 +149,7 @@ where
let alias = format!("{}{}", SelectB.as_str(), col.as_str());
selector.query().expr(SelectExpr {
expr: col.select_as(col.into_expr()),
alias: Some(SeaRc::new(Alias::new(&alias))),
alias: Some(SeaRc::new(Alias::new(alias))),
window: None,
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/query/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ where
{
let mut slf = self;
for (i, mut rel) in l.link().into_iter().enumerate() {
let to_tbl = Alias::new(&format!("r{i}")).into_iden();
let to_tbl = Alias::new(format!("r{i}")).into_iden();
let from_tbl = if i > 0 {
Alias::new(&format!("r{}", i - 1)).into_iden()
Alias::new(format!("r{}", i - 1)).into_iden()
} else {
unpack_table_ref(&rel.from_tbl)
};
Expand All @@ -96,12 +96,12 @@ where
for col in <T::Column as Iterable>::iter() {
let alias = format!("{}{}", SelectB.as_str(), col.as_str());
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(),
));
select_two.query().expr(SelectExpr {
expr: col.select_as(expr),
alias: Some(SeaRc::new(Alias::new(&alias))),
alias: Some(SeaRc::new(Alias::new(alias))),
window: None,
});
}
Expand Down

0 comments on commit 737a894

Please sign in to comment.