Skip to content

Expand parse without semicolons #1949

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aharpervc
Copy link
Contributor

This PR is a followup (ref) to recent work on parsing without requiring semicolon statement delimiters. It's the same content as my former PR which was stale after #1937.

This PR is rebased on latest master and brings forward the increased test coverage and additional parsing fixes from the previous branch.

Particularly, this PR expands support as follows:

  1. Added a supports_statements_without_semicolon_delimiter dialect trait function (default false, but true for SQL Server). Now we can set the default parser option based on the dialect
  2. Tightened up parsing logic, such as for when something is an alias or a keyword and comma delimited lists. When you write T-SQL without semicolons, you're going to have ambiguities, but being more selective here in the parser seems reasonable
  3. More test coverage & expanded test helper functions: statements_without_semicolons_parse_to which deletes semicolons from the string, then parses it (simplifies testing parsing with & without), all_dialects_requiring_semicolon_statement_delimiter & all_dialects_not_requiring_semicolon_statement_delimiter to find configured dialects, and assert_err_parse_statements to simplify asserting "end of statement" vs "an SQL statement" errors. A lot of test assertions that fail when requiring semicolons also fail when not requiring semicolons, but what precisely the parser will complain about could be different (again, if you write SQL this way, you accept that possibility). The helper functions enable running existing tests on dialects that don't require semicolons with minimal changes. The main usage there is in the "common" tests.

@aharpervc aharpervc force-pushed the expand-parse-without-semicolons branch from 1e0c2cc to 069ce0e Compare July 16, 2025 19:04
- a corresponding `supports_statements_without_semicolon_delimiter` Dialect trait function
- this is optional for SQL Server, so it's set to `true` for that dialect
- for the implementation, `RETURN` parsing needs to be tightened up to avoid ambiguity & tests that formerly asserted "end of statement" now maybe need to assert "an SQL statement"
- a new `assert_err_parse_statements` splits the dialects based on semicolon requirements & asserts the expected error message accordingly
- at least all of select/insert/update/delete (plus exec) can be added
@aharpervc aharpervc force-pushed the expand-parse-without-semicolons branch from 069ce0e to 9be2dad Compare July 16, 2025 19:15
@aharpervc
Copy link
Contributor Author

@alamb fyi, as previously discussed

@aharpervc aharpervc marked this pull request as ready for review July 16, 2025 19:17
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.

1 participant