Skip to content

Support optional semicolon between statements #1937

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

Merged
merged 3 commits into from
Jul 11, 2025

Conversation

yoavcloud
Copy link
Contributor

T-SQL scripts do not require a semicolon as a statement delimiter. Added a new parser option to not require semicolons, as introducing this at the dialect level seems to be very intrusive. Also added a tsql() function to create an MS SQL dialect for testing with the new option.

@@ -2480,3 +2492,15 @@ fn parse_mssql_grant() {
fn parse_mssql_deny() {
ms().verified_stmt("DENY SELECT ON my_table TO public, db_admin");
}

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a similar test or move this over to common.rs? thinking since this flag is being added to the parser itself, it feels a bit like it could be lost if only tested here within mssql

@@ -222,13 +222,17 @@ pub struct ParserOptions {
/// Controls how literal values are unescaped. See
/// [`Tokenizer::with_unescape`] for more details.
pub unescape: bool,
/// Controls if the parser expects a semi-colon token
/// between statements.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking it might be helpful if we include in the doc that the default is true?

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @yoavcloud!
cc @alamb

@iffyio iffyio changed the title Support for T-SQL Support optional semicolon between statements Jul 11, 2025
@iffyio iffyio merged commit bc2c4e2 into apache:main Jul 11, 2025
10 checks passed
@aharpervc
Copy link
Contributor

I went to rebase #1843 and noticed this PR had been merged. Great! I see we had similar thoughts on how to approach it. I closed my PR.

However, my PR also introduced a lot more testing for the feature missing from this PR. I'll open a separate PR for more test coverage if it turns out to be needed.

@alamb
Copy link
Contributor

alamb commented Jul 14, 2025

However, my PR also introduced a lot more testing for the feature missing from this PR. I'll open a separate PR for more test coverage if it turns out to be needed.

Havign some more test coverage would be great -- if you have the time to make one please ping me and I will be happy to review it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants