mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #33548 -- Used the ->> operator for KeyTransforms on SQLite 3.38+.
This commit is contained in:
parent
cf03aa4e94
commit
e456d5da3c
@ -385,10 +385,16 @@ class KeyTransform(Transform):
|
|||||||
datatype_values = ",".join(
|
datatype_values = ",".join(
|
||||||
[repr(datatype) for datatype in connection.ops.jsonfield_datatype_values]
|
[repr(datatype) for datatype in connection.ops.jsonfield_datatype_values]
|
||||||
)
|
)
|
||||||
return (
|
if connection.get_database_version() >= (3, 38):
|
||||||
"(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) "
|
return (
|
||||||
"THEN JSON_TYPE(%s, %%s) ELSE JSON_EXTRACT(%s, %%s) END)"
|
"(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) "
|
||||||
) % (lhs, datatype_values, lhs, lhs), (tuple(params) + (json_path,)) * 3
|
"THEN JSON_TYPE(%s, %%s) ELSE %s ->> %%s END)"
|
||||||
|
) % (lhs, datatype_values, lhs, lhs), (tuple(params) + (json_path,)) * 3
|
||||||
|
else:
|
||||||
|
return (
|
||||||
|
"(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) "
|
||||||
|
"THEN JSON_TYPE(%s, %%s) ELSE JSON_EXTRACT(%s, %%s) END)"
|
||||||
|
) % (lhs, datatype_values, lhs, lhs), (tuple(params) + (json_path,)) * 3
|
||||||
|
|
||||||
|
|
||||||
class KeyTextTransform(KeyTransform):
|
class KeyTextTransform(KeyTransform):
|
||||||
|
Loading…
Reference in New Issue
Block a user