Skip to content

Commit 3dc79d3

Browse files
authored
Update JSON path compilation for Django 6.0
compile_json_path is no longer defined in django.db.models.fields.json in Django 6.0
1 parent 87a6fae commit 3dc79d3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mssql/compiler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
from django.db.transaction import TransactionManagementError
1515
from django.db.utils import NotSupportedError
1616
if django.VERSION >= (3, 1):
17-
from django.db.models.fields.json import compile_json_path, KeyTransform as json_KeyTransform
17+
from django.db.models.fields.json import KeyTransform as json_KeyTransform
18+
if django.VERSION >= (3, 1) and django.VERSION < (6, 0):
19+
from django.db.models.fields.json import compile_json_path
1820
if django.VERSION >= (4, 2):
1921
from django.core.exceptions import EmptyResultSet, FullResultSet
2022

@@ -47,7 +49,7 @@ def _as_sql_greatest(self, compiler, connection):
4749

4850
def _as_sql_json_keytransform(self, compiler, connection):
4951
lhs, params, key_transforms = self.preprocess_lhs(compiler, connection)
50-
json_path = compile_json_path(key_transforms)
52+
json_path = connection.ops.compile_json_path(key_transforms)
5153
return (
5254
"COALESCE(JSON_QUERY(%s, '%s'), JSON_VALUE(%s, '%s'))" %
5355
((lhs, json_path) * 2)

0 commit comments

Comments
 (0)