-
-
Notifications
You must be signed in to change notification settings - Fork 750
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
Fix parsing types and add check to test in future #2652
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2652 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 163 163
Lines 12000 12014 +14
=========================================
+ Hits 12000 12014 +14
Continue to review full report at Codecov.
|
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.
Doh, tricky bug! Looks good overall. A few nitpicky suggestions about coding style.
if tree: | ||
|
||
# Check we don't have any base types or unparsable sections | ||
types = tree.type_set() |
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.
Nice!
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.
Yes I've been meaning to add an unparsable
check for ages. Stops code reviewers having to check for this. Pretty pleased we have this now. And checking for no base
segments is an added bonus.
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.
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
Co-authored-by: Barry Hart <barrywhart@yahoo.com>
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.
Looks good! I have some suggestions about removing "segment" or "grammar" from the segment types -- cosmetic stuff.
Brief summary of the change made
Fixes #2650 which was caused by statements which did not have a
type
set, so fell back tobase
type whereas rule L052 expected them to be statements.I've also added a change to L052 to raise these errors in future instead of a debugging error that is not checked in CI.
I also added types to all other segments that were missing them.
Finally I added a check to the generate_parse_fixture_yml.py script to check if any segment is set to
base
orunparsable
and alert in this case so we can catch this in future.Are there any other side effects of this change that we should be aware of?
As per above.
Pull Request checklist
Please confirm you have completed any of the necessary steps below.
Included test cases to demonstrate any code changes, which may be one or more of the following:
.yml
rule test cases intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withtox -e generate-fixture-yml
).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.