diff options
author | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2018-02-01 11:12:12 -0500 |
---|---|---|
committer | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2018-02-09 10:12:05 -0500 |
commit | 695d94255348302be2d804e2187eb61e15cbb412 (patch) | |
tree | 6d0ab734ac26b158358ceb5fc9a42b7b0c3bb064 /src/mongo/db/pipeline/expression.h | |
parent | d1b2515a2d7dd4a22222de7d8905d6dc6b1ab1be (diff) | |
download | mongo-695d94255348302be2d804e2187eb61e15cbb412.tar.gz |
SERVER-30523: dateFromParts should not reject out-of-range numbers for date/time properties
Diffstat (limited to 'src/mongo/db/pipeline/expression.h')
-rw-r--r-- | src/mongo/db/pipeline/expression.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h index 7d055e1a963..2e0d899ed12 100644 --- a/src/mongo/db/pipeline/expression.h +++ b/src/mongo/db/pipeline/expression.h @@ -910,16 +910,22 @@ private: boost::intrusive_ptr<Expression> timeZone); /** - * Evaluates the value in field as number, and makes sure it fits in the minValue..maxValue - * range. If the field is missing or empty, the function returns the defaultValue. + * This function checks whether a field is a number. + * + * If 'field' is null, the default value is returned trough the 'returnValue' out + * parameter and the function returns true. + * + * If 'field' is not null: + * - if the value is "nullish", the function returns false. + * - if the value can not be coerced to an integral value, a UserException is thrown. + * - otherwise, the coerced integral value is returned through the 'returnValue' + * out parameter, and the function returns true. */ - bool evaluateNumberWithinRange(const Document& root, - const Expression* field, + bool evaluateNumberWithDefault(const Document& root, + boost::intrusive_ptr<Expression> field, StringData fieldName, - int defaultValue, - int minValue, - int maxValue, - int* returnValue) const; + long long defaultValue, + long long* returnValue) const; boost::intrusive_ptr<Expression> _year; boost::intrusive_ptr<Expression> _month; |