Skip to content

Commit

Permalink
Transaction with BEGIN
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Oct 14, 2021
1 parent 9abfdf4 commit 75882b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/database/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ impl Transaction {
impl OpenTransaction {
fn init() -> Self {
Self {
stmts: Vec::new(),
stmts: vec![Statement::from_string(
DbBackend::Postgres,
"BEGIN".to_owned(),
)],
transaction_depth: 0,
}
}
Expand Down Expand Up @@ -321,6 +324,7 @@ mod tests {
db.into_transaction_log(),
vec![
Transaction::many(vec![
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
Statement::from_sql_and_values(
DbBackend::Postgres,
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
Expand Down Expand Up @@ -365,6 +369,7 @@ mod tests {
assert_eq!(
db.into_transaction_log(),
vec![Transaction::many(vec![
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
Statement::from_sql_and_values(
DbBackend::Postgres,
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
Expand Down Expand Up @@ -402,6 +407,7 @@ mod tests {
assert_eq!(
db.into_transaction_log(),
vec![Transaction::many(vec![
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
Statement::from_sql_and_values(
DbBackend::Postgres,
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
Expand Down Expand Up @@ -459,6 +465,7 @@ mod tests {
assert_eq!(
db.into_transaction_log(),
vec![Transaction::many(vec![
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
Statement::from_sql_and_values(
DbBackend::Postgres,
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
Expand Down
5 changes: 3 additions & 2 deletions tests/uuid_tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod common;

pub use common::{bakery_chain::*, setup::*, TestContext};
use sea_orm::{entity::*, entity::prelude::*, DatabaseConnection};
use sea_orm::{entity::prelude::*, entity::*, DatabaseConnection};

#[sea_orm_macros::test]
#[cfg(any(
Expand All @@ -27,7 +27,8 @@ pub async fn insert_metadata(db: &DatabaseConnection) -> Result<(), DbErr> {
bytes: vec![1, 2, 3],
date: Some(Date::from_ymd(2021, 9, 27)),
time: Some(Time::from_hms(11, 32, 55)),
}.into_active_model();
}
.into_active_model();

let result = metadata.clone().insert(db).await?;

Expand Down

0 comments on commit 75882b3

Please sign in to comment.