@@ -72,6 +72,7 @@ def _has_key_predicate(path, root_column=None, negated=False, as_path=False):
7272 return result
7373
7474
75+ @property
7576def has_key_check_simple_expression (self ):
7677 rhs = [self .rhs ] if not isinstance (self .rhs , (list , tuple )) else self .rhs
7778 return self .is_simple_column and all (key .isalnum () for key in rhs )
@@ -147,7 +148,7 @@ def key_transform_in(self, compiler, connection, as_path=False):
147148 Return MQL to check if a JSON path exists and that its values are in the
148149 set of specified values (rhs).
149150 """
150- if as_path and self .is_simple_expression ():
151+ if as_path and self .can_use_path ():
151152 return builtin_lookup_path (self , compiler , connection )
152153
153154 lhs_mql = process_lhs (self , compiler , connection )
@@ -226,6 +227,7 @@ def key_transform_numeric_lookup_mixin_path(self, compiler, connection):
226227 return builtin_lookup_path (self , compiler , connection )
227228
228229
230+ @property
229231def keytransform_is_simple_column (self ):
230232 previous = self
231233 while isinstance (previous , KeyTransform ):
@@ -242,11 +244,11 @@ def register_json_field():
242244 HasKey .mongo_operator = None
243245 HasKeyLookup .as_mql_path = partialmethod (has_key_lookup , as_path = True )
244246 HasKeyLookup .as_mql_expr = partialmethod (has_key_lookup , as_path = False )
245- HasKeyLookup .is_simple_expression = has_key_check_simple_expression
247+ HasKeyLookup .can_use_path = has_key_check_simple_expression
246248 HasKeys .mongo_operator = "$and"
247249 JSONExact .process_rhs = json_exact_process_rhs
248- KeyTransform .is_simple_column = property ( keytransform_is_simple_column )
249- KeyTransform .is_simple_expression = keytransform_is_simple_column
250+ KeyTransform .is_simple_column = keytransform_is_simple_column
251+ KeyTransform .can_use_path = keytransform_is_simple_column
250252 KeyTransform .as_mql_path = partialmethod (key_transform , as_path = True )
251253 KeyTransform .as_mql_expr = partialmethod (key_transform , as_path = False )
252254 KeyTransformExact .as_mql_expr = key_transform_exact_expr
0 commit comments