Skip to content

Commit b77a335

Browse files
committed
Edits.
1 parent a428b76 commit b77a335

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

django_mongodb_backend/fields/embedded_model_array.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,13 @@ def as_mql(self, compiler, connection):
141141
return {"$anyElementTrue": lhs_mql}
142142

143143

144-
class ArrayAggregationSubqueryMixin:
144+
@_EmbeddedModelArrayOutputField.register_lookup
145+
class EmbeddedModelArrayFieldIn(EmbeddedModelArrayFieldBuiltinLookup, lookups.In):
145146
def get_subquery_wrapping_pipeline(self, compiler, connection, field_name, expr):
146147
return [
147148
{
148149
"$facet": {
149-
"group": [
150+
"gathered_data": [
150151
{"$project": {"tmp_name": expr.as_mql(compiler, connection)}},
151152
{
152153
"$unwind": "$tmp_name",
@@ -166,7 +167,7 @@ def get_subquery_wrapping_pipeline(self, compiler, connection, field_name, expr)
166167
"$ifNull": [
167168
{
168169
"$getField": {
169-
"input": {"$arrayElemAt": ["$group", 0]},
170+
"input": {"$arrayElemAt": ["$gathered_data", 0]},
170171
"field": "tmp_name",
171172
}
172173
},
@@ -178,13 +179,6 @@ def get_subquery_wrapping_pipeline(self, compiler, connection, field_name, expr)
178179
]
179180

180181

181-
@_EmbeddedModelArrayOutputField.register_lookup
182-
class EmbeddedModelArrayFieldIn(
183-
EmbeddedModelArrayFieldBuiltinLookup, lookups.In, ArrayAggregationSubqueryMixin
184-
):
185-
pass
186-
187-
188182
@_EmbeddedModelArrayOutputField.register_lookup
189183
class EmbeddedModelArrayFieldExact(EmbeddedModelArrayFieldBuiltinLookup, lookups.Exact):
190184
pass

0 commit comments

Comments
 (0)