diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-01-10 21:00:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-10 21:00:42 +0100 |
| commit | 8d2c16252e78a0fae2356ead3a7b3f879a653046 (patch) | |
| tree | 4bd80eb8e8d85afe4a2875839b18a234cd0ac449 | |
| parent | f50184a84b885f4474d5030af968195219a360b9 (diff) | |
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.
| -rw-r--r-- | django/db/models/fields/json.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py index 7b9b2ae6b2..571e6e79f3 100644 --- a/django/db/models/fields/json.py +++ b/django/db/models/fields/json.py @@ -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) |
