-
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
Add support for DEFERRED, IMMEDIATE, and EXCLUSIVE in SQLite's BEGIN TRANSACTION command #1067
Conversation
Support the following syntaxes - BEGIN DEFERRED - BEGIN IMMEDIATE - BEGIN EXCLUSIVE
12370a2
to
1318e49
Compare
I found an implementation that looks better, so I will refactor this PR to take that into account. |
This commit f2ad35e is somewhat experimental, and I think it could be helpful for thoroughly testing all dialects. But I think it is a bit complex, so I don't mind at all switching to another approach. |
Pull Request Test Coverage Report for Build 7274283364Warning: This coverage report may be inaccurate.We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
💛 - Coveralls |
I agree it is fairly complex I think the more standard way for testing multiple dialects is to programatically construct This has all the available dialects -- perhaps you can derive the incude/exclude lists from that https://github.com/sqlparser-rs/sqlparser-rs/blob/64eccdbba2fbc69fdb76ee451a1c43e30e7bfe3c/src/test_utils.rs#L196-L213 instead as that already exists |
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.
Thank you for the contribution @takaebato . I have a suggestion on testing, but otherwise I think this PR looks very nice to me 👌
@@ -38,4 +38,8 @@ impl Dialect for GenericDialect { | |||
fn supports_group_by_expr(&self) -> bool { | |||
true | |||
} | |||
|
|||
fn supports_start_transaction_modifier(&self) -> bool { |
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.
👍
tests/sqlparser_sqlite.rs
Outdated
#[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 comment
The 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 SqliteDialect
and GenericDialect
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 comment
The 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..)
I first tried to pass the arguments like this
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.
error[E0277]: can't compare `dyn dialect::Dialect` with `dyn dialect::Dialect`
--> src/test_utils.rs:230:36
|
230 | .filter(|d| !dialect_names.contains(d))
| ^^^^^^^^ no implementation for `dyn dialect::Dialect == dyn dialect::Dialect`
|
= help: the trait `PartialEq` is not implemented for `dyn dialect::Dialect`
= note: required for `Box<dyn dialect::Dialect>` to implement `PartialEq`
I couldn't think of a suitable way to deal with this, so I changed to using String which can be compared.
But yes, this is not a good solution, so you can skip it!
Thanks! |
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.
Thank you @takaebato
This PR adds support for the following
BEGIN TRANSACTION
syntaxes in SQLite. docsBEGIN DEFERRED
BEGIN IMMEDIATE
BEGIN EXCLUSIVE
Since there was no term in the documentation to refer to the words
DEFERRED
,IMMEDIATE
, andEXCLUSIVE
, I decided to use the termmodifier
. The termmode
is also a candidate, but I avoided it to prevent confusion with transaction mode in standard SQL.This PR's implementation follows the approach used in previous PR with similar changes.I would love to hear any ideas for better naming or implementations!