Skip to content

Commit

Permalink
fix per Emanuel
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Dec 18, 2024
1 parent 616a418 commit 9d780fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions django_mongodb/aggregates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db.models.aggregates import Aggregate, Count, StdDev, Variance
from django.db.models.expressions import Case, Col, Value, When
from django.db.models.expressions import Case, Value, When
from django.db.models.lookups import IsNull

from .query_utils import process_lhs
Expand All @@ -16,7 +16,7 @@ def aggregate(
resolve_inner_expression=False,
**extra_context, # noqa: ARG001
):
if self.filter and not isinstance(self.filter, Col):
if self.filter:
node = self.copy()
node.filter = None
source_expressions = node.get_source_expressions()
Expand Down
2 changes: 1 addition & 1 deletion django_mongodb/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _prepare_expressions_for_pipeline(self, expression, target, annotation_group
rhs = sub_expr.as_mql(self, self.connection, resolve_inner_expression=True)
group[alias] = {"$addToSet": rhs}
replacing_expr = sub_expr.copy()
replacing_expr.set_source_expressions([inner_column])
replacing_expr.set_source_expressions([inner_column, None])
else:
group[alias] = sub_expr.as_mql(self, self.connection)
replacing_expr = inner_column
Expand Down

0 comments on commit 9d780fc

Please sign in to comment.