-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Fixed #31829 -- Used JSONField __contains lookup on key transforms. #13238
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
Conversation
6121960
to
760c73c
Compare
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.
@laymonage Thanks 👍 I left comments.
@laymonage Thanks 👍 I rebased from master and pushed small edits. |
@@ -695,8 +714,11 @@ def test_contains_contained_by_with_key_transform(self): | |||
)), | |||
), | |||
] | |||
# PostgreSQL requires a layer of nesting. | |||
if connection.vendor != 'postgresql': |
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.
This should be a feature flag as CockroachDB (which tries to emulate PostgreSQL in a lot of ways) has the same restriction.
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.
Agreed, Do you have any name suggestion?
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.
Proposal at #13255.
Ticket #31829.
I made a mistake and created a
KeyTransformContains
that's based onlookup.Contains
. This makes thecontains
lookup to not use JSON containment logic when it's performed on aKeyTransform
. Therefore, it's incompatible with the previous PostgreSQL implementation, which uses the overridden lookup.This PR fixes that by removing
KeyTransformContains
.The customJSON_CONTAINS
function on SQLite has also been extended to follow the rules ofJSON_CONTAINS
on MySQL. On Oracle, the implementation is turned into a chainedKeyTransformExact
lookup if therhs
is adict
, otherwise it falls back to the builtinlookup.Contains
.I also added notes to the docs, but I'm not sure if that's necessary.