Transaction with BEGIN
This commit is contained in:
parent
9abfdf4838
commit
75882b34cb
@ -227,7 +227,10 @@ impl Transaction {
|
|||||||
impl OpenTransaction {
|
impl OpenTransaction {
|
||||||
fn init() -> Self {
|
fn init() -> Self {
|
||||||
Self {
|
Self {
|
||||||
stmts: Vec::new(),
|
stmts: vec![Statement::from_string(
|
||||||
|
DbBackend::Postgres,
|
||||||
|
"BEGIN".to_owned(),
|
||||||
|
)],
|
||||||
transaction_depth: 0,
|
transaction_depth: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,6 +324,7 @@ mod tests {
|
|||||||
db.into_transaction_log(),
|
db.into_transaction_log(),
|
||||||
vec![
|
vec![
|
||||||
Transaction::many(vec![
|
Transaction::many(vec![
|
||||||
|
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
|
||||||
Statement::from_sql_and_values(
|
Statement::from_sql_and_values(
|
||||||
DbBackend::Postgres,
|
DbBackend::Postgres,
|
||||||
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
|
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
|
||||||
@ -365,6 +369,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
db.into_transaction_log(),
|
db.into_transaction_log(),
|
||||||
vec![Transaction::many(vec![
|
vec![Transaction::many(vec![
|
||||||
|
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
|
||||||
Statement::from_sql_and_values(
|
Statement::from_sql_and_values(
|
||||||
DbBackend::Postgres,
|
DbBackend::Postgres,
|
||||||
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
|
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
|
||||||
@ -402,6 +407,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
db.into_transaction_log(),
|
db.into_transaction_log(),
|
||||||
vec![Transaction::many(vec![
|
vec![Transaction::many(vec![
|
||||||
|
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
|
||||||
Statement::from_sql_and_values(
|
Statement::from_sql_and_values(
|
||||||
DbBackend::Postgres,
|
DbBackend::Postgres,
|
||||||
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
|
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
|
||||||
@ -459,6 +465,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
db.into_transaction_log(),
|
db.into_transaction_log(),
|
||||||
vec![Transaction::many(vec![
|
vec![Transaction::many(vec![
|
||||||
|
Statement::from_string(DbBackend::Postgres, "BEGIN".to_owned()),
|
||||||
Statement::from_sql_and_values(
|
Statement::from_sql_and_values(
|
||||||
DbBackend::Postgres,
|
DbBackend::Postgres,
|
||||||
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
|
r#"SELECT "cake"."id", "cake"."name" FROM "cake" LIMIT $1"#,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
|
|
||||||
pub use common::{bakery_chain::*, setup::*, TestContext};
|
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]
|
#[sea_orm_macros::test]
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
@ -27,7 +27,8 @@ pub async fn insert_metadata(db: &DatabaseConnection) -> Result<(), DbErr> {
|
|||||||
bytes: vec![1, 2, 3],
|
bytes: vec![1, 2, 3],
|
||||||
date: Some(Date::from_ymd(2021, 9, 27)),
|
date: Some(Date::from_ymd(2021, 9, 27)),
|
||||||
time: Some(Time::from_hms(11, 32, 55)),
|
time: Some(Time::from_hms(11, 32, 55)),
|
||||||
}.into_active_model();
|
}
|
||||||
|
.into_active_model();
|
||||||
|
|
||||||
let result = metadata.clone().insert(db).await?;
|
let result = metadata.clone().insert(db).await?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user