@@ -66,22 +66,18 @@ def get_lookup(self, name):
66
66
class EMFArrayRHSMixin :
67
67
def process_rhs (self , compiler , connection ):
68
68
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.
72
70
# If querying a subfield inside the array (i.e., a nested KeyTransform), use the output
73
71
# field of the subfield. Otherwise, use the base field of the array itself.
74
72
if isinstance (self .lhs , KeyTransform ):
75
73
get_db_prep_value = self .lhs ._lhs .output_field .get_db_prep_value
76
74
else :
77
75
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 )]
79
77
80
78
81
79
@EmbeddedModelArrayField .register_lookup
82
80
class EMFArrayExact (EMFArrayRHSMixin , lookups .Exact ):
83
- get_db_prep_lookup_value_is_iterable = False
84
-
85
81
def as_mql (self , compiler , connection ):
86
82
if not isinstance (self .lhs , KeyTransform ):
87
83
raise ValueError ("error" )
@@ -106,7 +102,6 @@ def as_mql(self, compiler, connection):
106
102
@EmbeddedModelArrayField .register_lookup
107
103
class ArrayOverlap (EMFArrayRHSMixin , Lookup ):
108
104
lookup_name = "overlap"
109
- get_db_prep_lookup_value_is_iterable = False
110
105
111
106
def as_mql (self , compiler , connection ):
112
107
# Querying a subfield within the array elements (via nested KeyTransform).
@@ -134,7 +129,6 @@ def as_mql(self, compiler, connection):
134
129
135
130
136
131
class KeyTransform (Transform ):
137
- # it should be different class than EMF keytransform even most of the methods are equal.
138
132
def __init__ (self , key_name , array_field , * args , ** kwargs ):
139
133
super ().__init__ (* args , ** kwargs )
140
134
self .array_field = array_field
@@ -174,12 +168,11 @@ def get_transform(self, name):
174
168
lookup on an embedded model's field.
175
169
"""
176
170
# Once the sub lhs is a transform, all the filter are applied over it.
171
+ # Otherwise get transform from EMF.
177
172
transform = (
178
173
self ._lhs .get_transform (name )
179
174
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 )
183
176
)
184
177
if transform :
185
178
self ._sub_transform = transform
0 commit comments