Skip to content
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

TSQL: allow leading GO #2997

Merged
merged 2 commits into from Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/sqlfluff/dialects/dialect_tsql.py
Expand Up @@ -2572,16 +2572,19 @@ class FileSegment(BaseFileSegment):

# NB: We don't need a match_grammar here because we're
# going straight into instantiating it directly usually.
parse_grammar = Delimited(
Ref("BatchSegment"),
delimiter=AnyNumberOf(
Sequence(
Ref("DelimiterGrammar", optional=True), Ref("BatchDelimiterGrammar")
parse_grammar = Sequence(
AnyNumberOf(Ref("BatchDelimiterGrammar")),
Delimited(
Ref("BatchSegment"),
delimiter=AnyNumberOf(
Sequence(
Ref("DelimiterGrammar", optional=True), Ref("BatchDelimiterGrammar")
),
min_times=1,
),
min_times=1,
allow_gaps=True,
allow_trailing=True,
),
allow_gaps=True,
allow_trailing=True,
)


Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/dialects/tsql/go_delimiters.sql
@@ -1,3 +1,5 @@
-- It's possible to have a file starting with GO
GO
-- It's possible to have multiple GO between batches.
SELECT foo FROM bar GO GO
SELECT foo FROM bar GO
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/dialects/tsql/go_delimiters.yml
Expand Up @@ -3,8 +3,10 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: 48ee8f3f556e82816f06c2f0155e2eb39630f07d23a9a0a7cf961d58d58df5eb
_hash: bd36bce2e40fe28989cdc56078defe2ddae2d528b37e5b717984c9a6e64041af
file:
- go_statement:
keyword: GO
- batch:
statement:
select_statement:
Expand Down