Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support recursive operator calls for $sum aggregation accumulator #3116

Merged
merged 18 commits into from
Jul 31, 2023
Next Next commit
wip
  • Loading branch information
noisersup committed Jul 26, 2023
commit 4711942a350bf7701ed179900bec25b74568b03c
1 change: 0 additions & 1 deletion integration/aggregate_documents_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,6 @@ func TestAggregateCompatGroupSum(t *testing.T) {
}}},
bson.D{{"$sort", bson.D{{"_id", -1}}}},
},
skip: "https://github.com/FerretDB/FerretDB/issues/2694",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func newSum(accumulation *types.Document) (Accumulator, error) {
"The $sum accumulator is a unary operator",
"$sum (accumulator)",
)
case *types.Document:
accumulator.number = int32(0)

case float64:
accumulator.number = expr
case string:
Expand All @@ -54,7 +57,6 @@ func newSum(accumulation *types.Document) (Accumulator, error) {
case int32, int64:
accumulator.number = expr
default:
// TODO https://github.com/FerretDB/FerretDB/issues/2694
accumulator.number = int32(0)
// $sum returns 0 on non-numeric field
}
Expand Down