diff options
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; } |