Skip to content

Commit 4181939

Browse files
committed
add additional assertion for parse_set_transaction test
Signed-off-by: poonai <[email protected]>
1 parent 97f3e65 commit 4181939

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

src/ast/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,11 @@ pub enum Statement {
786786
/// `{ BEGIN [ TRANSACTION | WORK ] | START TRANSACTION } ...`
787787
StartTransaction { modes: Vec<TransactionMode> },
788788
/// `SET TRANSACTION ...`
789-
SetTransaction { modes: Vec<TransactionMode>, snapshot: Option<Value>, session: bool },
789+
SetTransaction {
790+
modes: Vec<TransactionMode>,
791+
snapshot: Option<Value>,
792+
session: bool,
793+
},
790794
/// `COMMIT [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]`
791795
Commit { chain: bool },
792796
/// `ROLLBACK [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]`
@@ -1369,7 +1373,11 @@ impl fmt::Display for Statement {
13691373
}
13701374
Ok(())
13711375
}
1372-
Statement::SetTransaction { modes, snapshot, session } => {
1376+
Statement::SetTransaction {
1377+
modes,
1378+
snapshot,
1379+
session,
1380+
} => {
13731381
if *session {
13741382
write!(f, "SET SESSION CHARACTERISTICS AS TRANSACTION")?;
13751383
} else {
@@ -1378,7 +1386,7 @@ impl fmt::Display for Statement {
13781386
if !modes.is_empty() {
13791387
write!(f, " {}", display_comma_separated(modes))?;
13801388
}
1381-
if let Some(snapshot_id) = snapshot{
1389+
if let Some(snapshot_id) = snapshot {
13821390
write!(f, " SNAPSHOT {}", snapshot_id)?;
13831391
}
13841392
Ok(())

src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,13 +2683,13 @@ impl<'a> Parser<'a> {
26832683
return Ok(Statement::SetTransaction {
26842684
modes: vec![],
26852685
snapshot: Some(snaphot_id),
2686-
session: false
2686+
session: false,
26872687
});
26882688
}
26892689
Ok(Statement::SetTransaction {
26902690
modes: self.parse_transaction_modes()?,
26912691
snapshot: None,
2692-
session: false
2692+
session: false,
26932693
})
26942694
} else {
26952695
self.expected("equals sign or TO", self.peek_token())

tests/sqlparser_common.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,14 +3586,22 @@ fn parse_set_transaction() {
35863586
// TRANSACTION, so no need to duplicate the tests here. We just do a quick
35873587
// sanity check.
35883588
match verified_stmt("SET TRANSACTION READ ONLY, READ WRITE, ISOLATION LEVEL SERIALIZABLE") {
3589-
Statement::SetTransaction { modes, .. } => assert_eq!(
3589+
Statement::SetTransaction {
35903590
modes,
3591-
vec![
3592-
TransactionMode::AccessMode(TransactionAccessMode::ReadOnly),
3593-
TransactionMode::AccessMode(TransactionAccessMode::ReadWrite),
3594-
TransactionMode::IsolationLevel(TransactionIsolationLevel::Serializable),
3595-
]
3596-
),
3591+
session,
3592+
snapshot,
3593+
} => {
3594+
assert_eq!(
3595+
modes,
3596+
vec![
3597+
TransactionMode::AccessMode(TransactionAccessMode::ReadOnly),
3598+
TransactionMode::AccessMode(TransactionAccessMode::ReadWrite),
3599+
TransactionMode::IsolationLevel(TransactionIsolationLevel::Serializable),
3600+
]
3601+
);
3602+
assert_eq!(session, false);
3603+
assert_eq!(snapshot, None);
3604+
}
35973605
_ => unreachable!(),
35983606
}
35993607
}

0 commit comments

Comments
 (0)