-
-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adds find_with_linked test * WIP(related test) * mock related test done * complete relation test * loader update * find_with/also_related missing test case for empty from other side * comments fixup * revert loader test * related select test done * find with/also linked test cases * removed due to it being functionally same as the new one * fmt, remove excess import * improved model generation * issue related test case #1790 * added loader test cases and slight improvement to find_related/linked * miscellaneous changes * added empty insert, merge load_one test case * completed loader many to many test case, fmt * removed empty_insert test case for now * commented insert_test * added Cargo.toml for issue 1790's folder * buffed salvo version for ci(0.49 yanked) * revert version for salvo example
- Loading branch information
Showing
13 changed files
with
1,251 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[workspace] | ||
# A separate workspace | ||
|
||
[package] | ||
name = "sea-orm-issues-1790" | ||
version = "0.1.0" | ||
edition = "2023" | ||
publish = false | ||
|
||
[dependencies] | ||
anyhow = "1" | ||
serde = "1" | ||
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] } | ||
|
||
[dependencies.sea-orm] | ||
path = "../../" | ||
default-features = false | ||
features = ["macros", "runtime-tokio-native-tls", "sqlx-sqlite"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
mod tests { | ||
// currently ok | ||
#[test] | ||
fn insert_do_nothing_postgres() { | ||
assert_eq!( | ||
Insert::<cake::ActiveModel>::new() | ||
.add(cake::Model { | ||
id: 1, | ||
name: "Apple Pie".to_owned(), | ||
}) | ||
.on_conflict(OnConflict::new() | ||
.do_nothing() | ||
.to_owned() | ||
) | ||
.build(DbBackend::Postgres) | ||
.to_string(), | ||
r#"INSERT INTO "cake" ("id", "name") VALUES (1, 'Apple Pie') ON CONFLICT DO NOTHING"#, | ||
); | ||
} | ||
|
||
//failed to run | ||
#[test] | ||
fn insert_do_nothing_mysql() { | ||
assert_eq!( | ||
Insert::<cake::ActiveModel>::new() | ||
.add(cake::Model { | ||
id: 1, | ||
name: "Apple Pie".to_owned(), | ||
}) | ||
.on_conflict(OnConflict::new() | ||
.do_nothing() | ||
.to_owned() | ||
) | ||
.build(DbBackend::Mysql) | ||
.to_string(), | ||
r#"INSERT IGNORE INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#, | ||
); | ||
} | ||
|
||
// currently ok | ||
#[test] | ||
fn insert_do_nothing() { | ||
assert_eq!( | ||
Insert::<cake::ActiveModel>::new() | ||
.add(cake::Model { | ||
id: 1, | ||
name: "Apple Pie".to_owned(), | ||
}) | ||
.on_conflict(OnConflict::new() | ||
.do_nothing() | ||
.to_owned() | ||
) | ||
.build(DbBackend::Sqlite) | ||
.to_string(), | ||
r#"INSERT IGNORE INTO "cake" ("id", "name") VALUES (1, 'Apple Pie')"#, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.