Skip to content

Commit

Permalink
fix the wrong output query
Browse files Browse the repository at this point in the history
Signed-off-by: mahdihaghverdi <[email protected]>
  • Loading branch information
mahdihaghverdi committed Oct 30, 2023
1 parent 9408016 commit 3ebcb1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 7 additions & 9 deletions aggify/aggify.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,15 @@ def __to_aggregate(self, query: dict[str, Any]) -> None:
if match != {}:
matches.append(match)

self.pipelines.extend(
[
self.__lookup(
from_collection=from_collection._meta["collection"], # noqa
local_field=local_field,
as_name=as_name,
),
*[{"$match": match} for match in matches],
]
self.pipelines.append(
self.__lookup(
from_collection=from_collection._meta["collection"], # noqa
local_field=local_field,
as_name=as_name,
)
)
self.unwind(as_name)
self.pipelines.extend([{"$match": match} for match in matches])

@last_out_stage_check
def __getitem__(self, index: slice | int) -> "Aggify":
Expand Down
3 changes: 2 additions & 1 deletion tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class ParameterTestCase:
"localField": "owner_id",
}
},
{"$match": {"owner.deleted_at": None}},
{"$unwind": "$owner"},
{"$match": {"owner.deleted_at": None}},

],
),
ParameterTestCase(
Expand Down

0 comments on commit 3ebcb1c

Please sign in to comment.