@@ -66,22 +66,18 @@ def get_lookup(self, name):
6666class EMFArrayRHSMixin :
6767 def process_rhs (self , compiler , connection ):
6868 values = self .rhs
69- if not self .get_db_prep_lookup_value_is_iterable :
70- values = [values ]
71- # Compute how to serialize each value based on the query target.
69+ # Value must be serealized based on the query target.
7270 # If querying a subfield inside the array (i.e., a nested KeyTransform), use the output
7371 # field of the subfield. Otherwise, use the base field of the array itself.
7472 if isinstance (self .lhs , KeyTransform ):
7573 get_db_prep_value = self .lhs ._lhs .output_field .get_db_prep_value
7674 else :
7775 get_db_prep_value = self .lhs .output_field .base_field .get_db_prep_value
78- return None , [get_db_prep_value (v , connection , prepared = True ) for v in values ]
76+ return None , [get_db_prep_value (values , connection , prepared = True )]
7977
8078
8179@EmbeddedModelArrayField .register_lookup
8280class EMFArrayExact (EMFArrayRHSMixin , lookups .Exact ):
83- get_db_prep_lookup_value_is_iterable = False
84-
8581 def as_mql (self , compiler , connection ):
8682 if not isinstance (self .lhs , KeyTransform ):
8783 raise ValueError ("error" )
@@ -106,7 +102,6 @@ def as_mql(self, compiler, connection):
106102@EmbeddedModelArrayField .register_lookup
107103class ArrayOverlap (EMFArrayRHSMixin , Lookup ):
108104 lookup_name = "overlap"
109- get_db_prep_lookup_value_is_iterable = False
110105
111106 def as_mql (self , compiler , connection ):
112107 # Querying a subfield within the array elements (via nested KeyTransform).
@@ -134,7 +129,6 @@ def as_mql(self, compiler, connection):
134129
135130
136131class KeyTransform (Transform ):
137- # it should be different class than EMF keytransform even most of the methods are equal.
138132 def __init__ (self , key_name , array_field , * args , ** kwargs ):
139133 super ().__init__ (* args , ** kwargs )
140134 self .array_field = array_field
@@ -174,12 +168,11 @@ def get_transform(self, name):
174168 lookup on an embedded model's field.
175169 """
176170 # Once the sub lhs is a transform, all the filter are applied over it.
171+ # Otherwise get transform from EMF.
177172 transform = (
178173 self ._lhs .get_transform (name )
179174 if isinstance (self ._lhs , Transform )
180- else self .array_field .base_field .embedded_model ._meta .get_field (
181- self .key_name
182- ).get_transform (name )
175+ else self .array_field .embedded_model ._meta .get_field (self .key_name ).get_transform (name )
183176 )
184177 if transform :
185178 self ._sub_transform = transform
0 commit comments