Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump sea-query version #430

Merged
merged 3 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ futures-util = { version = "^0.3" }
tracing = { version = "0.1", features = ["log"] }
rust_decimal = { version = "^1", optional = true }
sea-orm-macros = { version = "^0.5.0", path = "sea-orm-macros", optional = true }
sea-query = { version = "^0.20.0", features = ["thread-safe"] }
sea-query = { version = "^0.21.0", features = ["thread-safe"] }
sea-strum = { version = "^0.23", features = ["derive", "sea-orm"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = { version = "^1", optional = true }
Expand Down
14 changes: 12 additions & 2 deletions src/query/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,21 @@ where
None => {
let col = match &sel.expr {
SimpleExpr::Column(col_ref) => match &col_ref {
ColumnRef::Column(col) | ColumnRef::TableColumn(_, col) => col,
ColumnRef::Column(col)
| ColumnRef::TableColumn(_, col)
| ColumnRef::SchemaTableColumn(_, _, col) => col,
ColumnRef::Asterisk | ColumnRef::TableAsterisk(_) => {
panic!("cannot apply alias for Column with asterisk")
}
},
SimpleExpr::AsEnum(_, simple_expr) => match simple_expr.as_ref() {
SimpleExpr::Column(col_ref) => match &col_ref {
ColumnRef::Column(col) | ColumnRef::TableColumn(_, col) => col,
ColumnRef::Column(col)
| ColumnRef::TableColumn(_, col)
| ColumnRef::SchemaTableColumn(_, _, col) => col,
ColumnRef::Asterisk | ColumnRef::TableAsterisk(_) => {
panic!("cannot apply alias for AsEnum with asterisk")
}
},
_ => {
panic!("cannot apply alias for AsEnum with expr other than Column")
Expand Down
2 changes: 1 addition & 1 deletion src/query/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ macro_rules! debug_query_stmt {
/// let raw_sql = debug_query!(&c, DbBackend::Sqlite);
/// assert_eq!(
/// raw_sql,
/// r#"INSERT INTO `cake` (`id`, `name`) VALUES (1, 'Apple Pie')"#
/// r#"INSERT INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#
/// );
/// ```
#[macro_export]
Expand Down
80 changes: 68 additions & 12 deletions tests/active_enum_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,14 @@ mod tests {
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
{
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
_select.build(DbBackend::Sqlite).to_string(),
[
r#"SELECT "active_enum_child"."id", "active_enum_child"."parent_id", "active_enum_child"."category", "active_enum_child"."color", "active_enum_child"."tea""#,
r#"FROM "active_enum_child""#,
r#"INNER JOIN "active_enum" ON "active_enum"."id" = "active_enum_child"."parent_id""#,
r#"WHERE "active_enum"."id" = 1"#,
]
.join(" ")
);
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
Expand Down Expand Up @@ -435,8 +441,16 @@ mod tests {
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
{
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
_select.build(DbBackend::Sqlite).to_string(),
_select
.build(DbBackend::Sqlite)
.to_string(),
[
r#"SELECT "active_enum"."id" AS "A_id", "active_enum"."category" AS "A_category", "active_enum"."color" AS "A_color", "active_enum"."tea" AS "A_tea","#,
r#""active_enum_child"."id" AS "B_id", "active_enum_child"."parent_id" AS "B_parent_id", "active_enum_child"."category" AS "B_category", "active_enum_child"."color" AS "B_color", "active_enum_child"."tea" AS "B_tea""#,
r#"FROM "active_enum""#,
r#"LEFT JOIN "active_enum_child" ON "active_enum"."id" = "active_enum_child"."parent_id""#,
]
.join(" ")
);
assert_eq!(
_select
Expand Down Expand Up @@ -478,8 +492,14 @@ mod tests {
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
{
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
_select.build(DbBackend::Sqlite).to_string(),
[
r#"SELECT "active_enum_child"."id", "active_enum_child"."parent_id", "active_enum_child"."category", "active_enum_child"."color", "active_enum_child"."tea""#,
r#"FROM "active_enum_child""#,
r#"INNER JOIN "active_enum" AS "r0" ON "r0"."id" = "active_enum_child"."parent_id""#,
r#"WHERE "r0"."id" = 1"#,
]
.join(" ")
);
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
Expand Down Expand Up @@ -508,8 +528,16 @@ mod tests {
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
{
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
_select.build(DbBackend::Sqlite).to_string(),
_select
.build(DbBackend::Sqlite)
.to_string(),
[
r#"SELECT "active_enum"."id" AS "A_id", "active_enum"."category" AS "A_category", "active_enum"."color" AS "A_color", "active_enum"."tea" AS "A_tea","#,
r#""r0"."id" AS "B_id", "r0"."parent_id" AS "B_parent_id", "r0"."category" AS "B_category", "r0"."color" AS "B_color", "r0"."tea" AS "B_tea""#,
r#"FROM "active_enum""#,
r#"LEFT JOIN "active_enum_child" AS "r0" ON "active_enum"."id" = "r0"."parent_id""#,
]
.join(" ")
);
assert_eq!(
_select
Expand Down Expand Up @@ -552,8 +580,14 @@ mod tests {
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
{
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
_select.build(DbBackend::Sqlite).to_string(),
[
r#"SELECT "active_enum"."id", "active_enum"."category", "active_enum"."color", "active_enum"."tea""#,
r#"FROM "active_enum""#,
r#"INNER JOIN "active_enum_child" ON "active_enum_child"."parent_id" = "active_enum"."id""#,
r#"WHERE "active_enum_child"."id" = 1"#,
]
.join(" ")
);
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
Expand Down Expand Up @@ -582,8 +616,16 @@ mod tests {
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
{
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
_select.build(DbBackend::Sqlite).to_string(),
_select
.build(DbBackend::Sqlite)
.to_string(),
[
r#"SELECT "active_enum_child"."id" AS "A_id", "active_enum_child"."parent_id" AS "A_parent_id", "active_enum_child"."category" AS "A_category", "active_enum_child"."color" AS "A_color", "active_enum_child"."tea" AS "A_tea","#,
r#""active_enum"."id" AS "B_id", "active_enum"."category" AS "B_category", "active_enum"."color" AS "B_color", "active_enum"."tea" AS "B_tea""#,
r#"FROM "active_enum_child""#,
r#"LEFT JOIN "active_enum" ON "active_enum_child"."parent_id" = "active_enum"."id""#,
]
.join(" ")
);
assert_eq!(
_select
Expand Down Expand Up @@ -626,8 +668,14 @@ mod tests {
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
{
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
_select.build(DbBackend::Sqlite).to_string(),
[
r#"SELECT "active_enum"."id", "active_enum"."category", "active_enum"."color", "active_enum"."tea""#,
r#"FROM "active_enum""#,
r#"INNER JOIN "active_enum_child" AS "r0" ON "r0"."parent_id" = "active_enum"."id""#,
r#"WHERE "r0"."id" = 1"#,
]
.join(" ")
);
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
Expand Down Expand Up @@ -656,8 +704,16 @@ mod tests {
#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-sqlite"))]
{
assert_eq!(
_select.build(DbBackend::MySql).to_string(),
_select.build(DbBackend::Sqlite).to_string(),
_select
.build(DbBackend::Sqlite)
.to_string(),
[
r#"SELECT "active_enum_child"."id" AS "A_id", "active_enum_child"."parent_id" AS "A_parent_id", "active_enum_child"."category" AS "A_category", "active_enum_child"."color" AS "A_color", "active_enum_child"."tea" AS "A_tea","#,
r#""r0"."id" AS "B_id", "r0"."category" AS "B_category", "r0"."color" AS "B_color", "r0"."tea" AS "B_tea""#,
r#"FROM "active_enum_child""#,
r#"LEFT JOIN "active_enum" AS "r0" ON "active_enum_child"."parent_id" = "r0"."id""#,
]
.join(" ")
);
assert_eq!(
_select
Expand Down