-
-
Notifications
You must be signed in to change notification settings - Fork 845
Support variables with dot in python templater #5872
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
Support variables with dot in python templater #5872
Conversation
…cessed using dot notation in python format strings
Coverage Results ✅
|
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.
Initially I didn't like this hack, but I think I'm warming to it.
It's definitely a hack, but it's a convenient one, and I think a pragmatic one. Good work 👍 .
I've got a couple of notes on how to make this clearer and easier for the user to understand. Likewise, making it clear when it fails so that the user knows what's happening.
Oh and on the merge conflict, I split out a lot of the very large config files as part of #6052 . The file that your edits should now go in is |
Co-authored-by: Alan Cruickshank <alan+git@designingoverload.com>
…lfluff into python-templater-variables-dot-notation # Conflicts: # docs/source/configuration.rst # src/sqlfluff/core/templaters/python.py
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 good work. I've added a test case to cover your new exception messages 👍 .
Sorry for the delayed review here.
Brief summary of the change made
fixes #5871
Adds support for python format strings containing variables with dot notation by temporarily converting these variables into a dictionary lookup using the fixed context key
sqlfluff
.I believe this is the simplest, most straightforward solution to this issue. Adding this "magic" context key into configuration might not be intuitive at first, but I think it can be easily understood through the documentation.
Are there any other side effects of this change that we should be aware of?
No
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.