-
Notifications
You must be signed in to change notification settings - Fork 583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for DEFERRED, IMMEDIATE, and EXCLUSIVE in SQLite's BEGIN TRANSACTION command #1067
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ use test_utils::*; | |
use sqlparser::ast::SelectItem::UnnamedExpr; | ||
use sqlparser::ast::*; | ||
use sqlparser::dialect::{GenericDialect, SQLiteDialect}; | ||
use sqlparser::parser::ParserOptions; | ||
use sqlparser::parser::{ParserError, ParserOptions}; | ||
use sqlparser::tokenizer::Token; | ||
|
||
#[test] | ||
|
@@ -431,6 +431,35 @@ fn invalid_empty_list() { | |
); | ||
} | ||
|
||
#[test] | ||
fn parse_start_transaction_with_modifier() { | ||
let (supported_dialects, unsupported_dialects) = | ||
partition_all_dialects_by_inclusion(vec!["generic", "sqlite"]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it isn't clear to me that using a String is preferable here to simply explicitly referring to Using a string defers any errors to runtime rather than compile time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback! (I have not yet been able to learn Rust properly, so I may be missing the point..) partition_all_dialects_by_inclusion(vec![Box::new(SQLiteDialect {}), Box::new(GenericDialect {})]) but I got the following error indicating that trait objects cannot be compared.
I couldn't think of a suitable way to deal with this, so I changed to using String which can be compared. |
||
|
||
supported_dialects.verified_stmt("BEGIN DEFERRED TRANSACTION"); | ||
supported_dialects.verified_stmt("BEGIN IMMEDIATE TRANSACTION"); | ||
supported_dialects.verified_stmt("BEGIN EXCLUSIVE TRANSACTION"); | ||
supported_dialects.one_statement_parses_to("BEGIN DEFERRED", "BEGIN DEFERRED TRANSACTION"); | ||
supported_dialects.one_statement_parses_to("BEGIN IMMEDIATE", "BEGIN IMMEDIATE TRANSACTION"); | ||
supported_dialects.one_statement_parses_to("BEGIN EXCLUSIVE", "BEGIN EXCLUSIVE TRANSACTION"); | ||
|
||
let res = unsupported_dialects.parse_sql_statements("BEGIN DEFERRED"); | ||
assert_eq!( | ||
ParserError::ParserError("Expected end of statement, found: DEFERRED".to_string()), | ||
res.unwrap_err(), | ||
); | ||
let res = unsupported_dialects.parse_sql_statements("BEGIN IMMEDIATE"); | ||
assert_eq!( | ||
ParserError::ParserError("Expected end of statement, found: IMMEDIATE".to_string()), | ||
res.unwrap_err(), | ||
); | ||
let res = unsupported_dialects.parse_sql_statements("BEGIN EXCLUSIVE"); | ||
assert_eq!( | ||
ParserError::ParserError("Expected end of statement, found: EXCLUSIVE".to_string()), | ||
res.unwrap_err(), | ||
); | ||
} | ||
|
||
fn sqlite() -> TestedDialects { | ||
TestedDialects { | ||
dialects: vec![Box::new(SQLiteDialect {})], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍