-
-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
148 additions
and
1 deletion.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
pub mod common; | ||
|
||
pub use common::{features::*, setup::*, TestContext}; | ||
use pretty_assertions::assert_eq; | ||
use sea_orm::{entity::prelude::*, ConnectionTrait, DatabaseConnection}; | ||
|
||
#[sea_orm_macros::test] | ||
#[cfg(any( | ||
feature = "sqlx-mysql", | ||
feature = "sqlx-sqlite", | ||
feature = "sqlx-postgres" | ||
))] | ||
async fn main() -> Result<(), DbErr> { | ||
let ctx = TestContext::new("execute_unprepared_tests").await; | ||
create_tables(&ctx.db).await?; | ||
execute_unprepared(&ctx.db).await?; | ||
ctx.delete().await; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub async fn execute_unprepared(db: &DatabaseConnection) -> Result<(), DbErr> { | ||
use insert_default::*; | ||
|
||
db.execute_unprepared( | ||
[ | ||
"INSERT INTO insert_default VALUES (1), (2), (3), (4), (5)", | ||
"DELETE FROM insert_default WHERE id % 2 = 0", | ||
] | ||
.join(";") | ||
.as_str(), | ||
) | ||
.await?; | ||
|
||
assert_eq!( | ||
Entity::find().all(db).await?, | ||
vec![Model { id: 1 }, Model { id: 3 }, Model { id: 5 },] | ||
); | ||
|
||
Ok(()) | ||
} |