|
24 | 24 | if VERSION >= (3, 1): |
25 | 25 | from django.db.models.fields.json import ( |
26 | 26 | KeyTransform, KeyTransformIn, KeyTransformExact, |
27 | | - HasKeyLookup, compile_json_path) |
28 | | - |
| 27 | + HasKeyLookup) |
| 28 | +if VERSION >= (3, 1) and VERSION < (6, 0): |
| 29 | + from django.db.models.fields.json import compile_json_path |
| 30 | + |
29 | 31 | if VERSION >= (3, 2): |
30 | 32 | from django.db.models.functions.math import Random |
31 | 33 |
|
@@ -327,7 +329,10 @@ def _combine_conditions(conditions): |
327 | 329 | if isinstance(self.lhs, KeyTransform): |
328 | 330 | # If lhs is a KeyTransform, preprocess to get SQL and JSON path |
329 | 331 | lhs, _, lhs_key_transforms = self.lhs.preprocess_lhs(compiler, connection) |
330 | | - lhs_json_path = compile_json_path(lhs_key_transforms) |
| 332 | + if VERSION >= (6, 0): |
| 333 | + lhs_json_path = connection.ops.compile_json_path(lhs_key_transforms) |
| 334 | + else: |
| 335 | + lhs_json_path = compile_json_path(lhs_key_transforms) |
331 | 336 | lhs_params = [] |
332 | 337 | else: |
333 | 338 | # Otherwise, process lhs normally and set default JSON path |
@@ -355,7 +360,10 @@ def _combine_conditions(conditions): |
355 | 360 | if VERSION >= (4, 1): |
356 | 361 | # For Django 4.1+, split out the final key and build the JSON path accordingly |
357 | 362 | *rhs_key_transforms, final_key = rhs_key_transforms |
358 | | - rhs_json_path = compile_json_path(rhs_key_transforms, include_root=False) |
| 363 | + if VERSION >= (6, 0): |
| 364 | + rhs_json_path = connection.ops.compile_json_path(rhs_key_transforms, include_root=False) |
| 365 | + else: |
| 366 | + rhs_json_path = compile_json_path(rhs_key_transforms, include_root=False) |
359 | 367 | rhs_json_path += self.compile_json_path_final_key(final_key) |
360 | 368 | rhs_params.append(lhs_json_path + rhs_json_path) |
361 | 369 | else: |
|
0 commit comments