-
Notifications
You must be signed in to change notification settings - Fork 45
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
[IMP] util.explode_query_range: replace problematic parallel_filter
…
#142
Open
Pirols
wants to merge
2
commits into
odoo:master
Choose a base branch
from
odoo-dev:master-remove_explode_query_range_format-pied
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[IMP] util.explode_query_range: replace problematic parallel_filter
…
#142
Pirols
wants to merge
2
commits into
odoo:master
from
odoo-dev:master-remove_explode_query_range_format-pied
+46
−5
Conversation
This file contains 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
Pirols
force-pushed
the
master-remove_explode_query_range_format-pied
branch
from
September 26, 2024 10:06
bf79fa6
to
96a474e
Compare
Pirols
force-pushed
the
master-remove_explode_query_range_format-pied
branch
2 times, most recently
from
September 26, 2024 11:03
210ef0a
to
e800de2
Compare
aj-fuentes
reviewed
Sep 26, 2024
Pirols
force-pushed
the
master-remove_explode_query_range_format-pied
branch
2 times, most recently
from
September 26, 2024 11:18
2b341f2
to
fd3ad98
Compare
aj-fuentes
reviewed
Sep 26, 2024
Pirols
force-pushed
the
master-remove_explode_query_range_format-pied
branch
4 times, most recently
from
September 26, 2024 15:02
1e35f62
to
8bbcc71
Compare
… formatting The usage of `str.format` to inject the parallel filter used to explode queries is not robust to the presence of other curly braces. Examples: 1. `JSON` strings (typically to leverage their mapping capabilities): see 79f3d71, where a query had to be modified to accomodate that. 2. Hardcoded sets of curly braces: ```python >>> "UPDATE t SET c = '{usage as literal characters}' WHERE {parallel_filter}".format(parallel_filter="…") Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 'usage as literal characters' ``` Which can be (unelegantly) solved adding even more braces, leveraging one side-effect of `.format`: ```python >>> "UPDATE t SET c = '{{usage as literal characters}}' WHERE {parallel_filter}".format(parallel_filter="…") "UPDATE t SET c = '{usage as literal characters}' WHERE …" ``` 3. Hardcoded curly braces (AFAICT no way to solve this): ```python >>> "UPDATE t SET c = 'this is an open curly brace = {' WHERE {parallel_filter}".format(parallel_filter="…") Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: unexpected '{' in field name ``` ```python >>> "UPDATE t SET c = 'this is a close brace = }' WHERE {parallel_filter}".format(parallel_filter="…") Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Single '}' encountered in format string ```
Pirols
force-pushed
the
master-remove_explode_query_range_format-pied
branch
from
September 26, 2024 15:03
8bbcc71
to
6299ef9
Compare
aj-fuentes
reviewed
Sep 27, 2024
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.
nits
…filter` formatting
Pirols
force-pushed
the
master-remove_explode_query_range_format-pied
branch
from
September 27, 2024 09:57
6299ef9
to
faf43c0
Compare
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.
… formatting
The usage of
str.format
to inject the parallel filter used to explode queries is not robust to the presence of other curly braces. Examples:JSON
strings (typically to leverage their mapping capabilities):see 79f3d71, where a query had to be modified to accomodate that.
Which can be (unelegantly) solved adding even more braces, leveraging one side-effect of
.format
: