fix(jinja): expose dialect-escaped companion value on get_filters()#40531
Draft
sha174n wants to merge 7 commits into
Draft
fix(jinja): expose dialect-escaped companion value on get_filters()#40531sha174n wants to merge 7 commits into
sha174n wants to merge 7 commits into
Conversation
Add an `escaped_val` key to the dict returned by `ExtraCache.get_filters()`
and `_get_filters_from_query_context()` whenever a SQL dialect is
configured. The value is produced via `String().literal_processor`,
the same path already used by `url_param`, so the escape rules track
the active dialect. `val` continues to expose the raw value for
non-SQL uses such as comparison, logging, or feeding `where_in`.
The companion key is opt-in for templates: only callers that read
`filter.get('escaped_val')` see the processed form, so existing
templates and consumers are unaffected. The docstring example now
demonstrates the `LIKE` interpolation pattern with `escaped_val`,
replacing the manual `replace("'", "''")` snippet that worked for
only a subset of dialects.
Unit tests cover the string, list-of-string, and
query_context_filters paths, plus a no-dialect case asserting the
key is absent so the previous return schema is preserved.
Contributor
|
Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️ Please read our New Contributor Welcome & Expectations guide. We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40531 +/- ##
==========================================
- Coverage 63.97% 63.96% -0.01%
==========================================
Files 2654 2654
Lines 142753 142768 +15
Branches 32833 32838 +5
==========================================
+ Hits 91325 91327 +2
- Misses 49870 49883 +13
Partials 1558 1558
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…er-escape-helper-202605292158
…er-escape-helper-202605292158
…er-escape-helper-202605292158
…er-escape-helper-202605292158
…er-escape-helper-202605292158
…er-escape-helper-202605292158
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.
ExtraCache.get_filters()and_get_filters_from_query_context()now expose a companionescaped_valkey on each returned filter dict whenever a SQL dialect is configured. The value is produced viaString().literal_processor, the same path already used byurl_param, so the quoting rules track the active dialect.valcontinues to carry the raw value for non-SQL uses (comparison, logging,where_in). The companion key is opt-in: only templates that readfilter.get('escaped_val')see the processed form, so existing templates and downstream consumers are unaffected. The docstring example now demonstrates theLIKEinterpolation pattern withescaped_val, replacing the manualreplace("'", "''")snippet that worked only for a subset of dialects.Unit tests cover the string, list-of-string, and
query_context_filterspaths, plus a no-dialect case asserting the key is absent so the prior return schema is preserved.Testing
pytest tests/unit_tests/jinja_context_test.py -k get_filtersChecklist