Transaction with BEGIN
This commit is contained in:
parent
9abfdf4838
commit
75882b34cb
@ -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,
|
||||
}
|
||||
}
|
||||
@ -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"#,
|
||||
@ -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"#,
|
||||
@ -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"#,
|
||||
@ -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"#,
|
||||
|
@ -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(
|
||||
@ -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?;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user