diff options
author | Geert Bosch <geert@mongodb.com> | 2016-06-01 22:52:44 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2016-06-06 13:22:34 -0400 |
commit | 00ed8f3b275971093ddd2ee7d3ab558904e28af0 (patch) | |
tree | 40db921cee44c6880f13be30521e3124eabd2bf2 /src/mongo/db/pipeline/value.cpp | |
parent | 666ce720ebf90229e8e4f92f8719284bedb4f20f (diff) | |
download | mongo-00ed8f3b275971093ddd2ee7d3ab558904e28af0.tar.gz |
SERVER-19735: Add support for decimal type in aggregationr3.3.8
Diffstat (limited to 'src/mongo/db/pipeline/value.cpp')
-rw-r--r-- | src/mongo/db/pipeline/value.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/value.cpp b/src/mongo/db/pipeline/value.cpp index 8a37c51067c..37b3b88afae 100644 --- a/src/mongo/db/pipeline/value.cpp +++ b/src/mongo/db/pipeline/value.cpp @@ -971,8 +971,6 @@ BSONType Value::getWidestNumeric(BSONType lType, BSONType rType) { return Undefined; } -// TODO: Add Decimal128 support to Value::integral() -// SERVER-19735 bool Value::integral() const { switch (getType()) { case NumberInt: @@ -984,6 +982,13 @@ bool Value::integral() const { return (_storage.doubleValue <= numeric_limits<int>::max() && _storage.doubleValue >= numeric_limits<int>::min() && _storage.doubleValue == static_cast<int>(_storage.doubleValue)); + case NumberDecimal: { + // If we are able to convert the decimal to an int32_t without an rounding errors, + // then it is integral. + uint32_t signalingFlags = Decimal128::kNoFlag; + (void)_storage.getDecimal().toInt(&signalingFlags); + return signalingFlags == Decimal128::kNoFlag; + } default: return false; } |