Fix DECLARE statements in STORED PROCEDURES (#44)#47
Open
windiana42 wants to merge 5 commits intomainfrom
Open
Fix DECLARE statements in STORED PROCEDURES (#44)#47windiana42 wants to merge 5 commits intomainfrom
windiana42 wants to merge 5 commits intomainfrom
Conversation
Since no files from .idea/ are in the repo, I suggest to put it in .gitignore. The version mentioned in the comment is nice for repos that do like to commit a basic PyCharm config: https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
In case of isolate_top_level_statements=True, copy DECLARE statements to subsequent statements only if they are top level.
Closed
svengiegerich
added a commit
that referenced
this pull request
Oct 30, 2023
Author
|
@SimeonStoykovQC do you expect this to be resolved by #56? |
Comment on lines
+24893
to
+24899
| @staticmethod | ||
| def is_top_level_statement(node: ParserRuleContext): | ||
| """Check wether node is a top level SQL statement.""" | ||
| cur = node.parentCtx | ||
| while isinstance(cur, tsqlParser.Sql_clauseContext) or isinstance(cur, tsqlParser.Sql_clausesContext): | ||
| cur = cur.parentCtx | ||
| return isinstance(cur, tsqlParser.BatchContext) |
Member
There was a problem hiding this comment.
I think this file is autogenerated from the ANTLR grammar and we shouldn't modify it manually
Member
From what I remember, #56 and #59 just add things to the grammar, but no new functionality around it. Here it looks like you need to change our logic around it? By the way, we try to be in sync with the ANTLR grammar (there is a CI job that syncs it regularly), so if you also want to push grammar changes, consider doing it upstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Copy DECLARE statements to subsequent statements only if they appear top level.
This fixes errors raised for
CREATE PROCEDURE CREATEALLDATES ( @StartDate AS DATE, @EndDate AS DATE ) AS DECLARE @Current AS DATE = DATEADD(DD, 0, @StartDate); DROP TABLE IF EXISTS ##alldates CREATE TABLE ##alldates ( dt DATE PRIMARY KEY ) WHILE @Current <= @EndDate BEGIN INSERT INTO ##alldates VALUES (@Current); SET @Current = DATEADD(DD, 1, @Current) -- add 1 to current day END GO IF OBJECT_ID ( N'dbo.get_db_sampling_factor' , N'FN' ) IS NOT NULL DROP FUNCTION get_db_sampling_factor ; GO