Fixed #34769 -- Fixed key transforms on Oracle 21c+.

Oracle 21c introduced support for primivites in JSON fields that
caused changes in handling them by JSON_QUERY/JSON_VALUE functions.
This commit is contained in:
Mariusz Felisiak 2024-01-10 21:00:42 +01:00 committed by GitHub
parent f50184a84b
commit 8d2c16252e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -352,10 +352,13 @@ class KeyTransform(Transform):
def as_oracle(self, compiler, connection):
lhs, params, key_transforms = self.preprocess_lhs(compiler, connection)
json_path = compile_json_path(key_transforms)
return (
"COALESCE(JSON_QUERY(%s, '%s'), JSON_VALUE(%s, '%s'))"
% ((lhs, json_path) * 2)
), tuple(params) * 2
if connection.features.supports_primitives_in_json_field:
sql = (
"COALESCE(JSON_VALUE(%s, '%s'), JSON_QUERY(%s, '%s' DISALLOW SCALARS))"
)
else:
sql = "COALESCE(JSON_QUERY(%s, '%s'), JSON_VALUE(%s, '%s'))"
return sql % ((lhs, json_path) * 2), tuple(params) * 2
def as_postgresql(self, compiler, connection):
lhs, params, key_transforms = self.preprocess_lhs(compiler, connection)