diff options
author | Mathias Stearn <mathias@10gen.com> | 2012-12-05 18:55:25 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2012-12-10 18:54:04 -0500 |
commit | 459467c7cf47b57d8990eeb41c65b4e203e15b65 (patch) | |
tree | e1b969346a3c8f42ff60a078469b86316dd3c3c0 /src/mongo/db/pipeline/accumulator_min_max.cpp | |
parent | fefb4334afe40664438668a289c6daed6813b3c3 (diff) | |
download | mongo-459467c7cf47b57d8990eeb41c65b4e203e15b65.tar.gz |
Normalize handling of Undefined vs EOO/missing in agg
Related tickets:
SERVER-6571 replace use of Undefined as missing with EOO
SERVER-6471 ignore nullish values in $min and $max accumulators
SERVER-6144 divide by zero makes field disappear (this solution isn't final)
Diffstat (limited to 'src/mongo/db/pipeline/accumulator_min_max.cpp')
-rwxr-xr-x | src/mongo/db/pipeline/accumulator_min_max.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/accumulator_min_max.cpp b/src/mongo/db/pipeline/accumulator_min_max.cpp index bc48b6fb480..86172cb3338 100755 --- a/src/mongo/db/pipeline/accumulator_min_max.cpp +++ b/src/mongo/db/pipeline/accumulator_min_max.cpp @@ -25,17 +25,15 @@ namespace mongo { verify(vpOperand.size() == 1); Value prhs(vpOperand[0]->evaluate(pDocument)); - /* if this is the first value, just use it */ - if (pValue.missing()) - pValue = prhs; - else { + // nullish values should have no impact on result + if (!prhs.nullish()) { /* compare with the current value; swap if appropriate */ int cmp = Value::compare(pValue, prhs) * sense; - if (cmp > 0) + if (cmp > 0 || pValue.missing()) // missing is lower than all other values pValue = prhs; } - return pValue; + return Value(); } AccumulatorMinMax::AccumulatorMinMax(int theSense): |