diff options
Diffstat (limited to 'src/mongo/db/pipeline/document_source_densify.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_densify.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp index 0325dbaa775..740ef193431 100644 --- a/src/mongo/db/pipeline/document_source_densify.cpp +++ b/src/mongo/db/pipeline/document_source_densify.cpp @@ -56,6 +56,10 @@ RangeStatement RangeStatement::parse(RangeSpec spec) { optional<TimeUnit> unit = [&]() { if (auto unit = spec.getUnit()) { + uassert(6586400, + "The step parameter in a range statement must be a whole number when " + "densifying a date range", + step.integral64Bit()); return optional<TimeUnit>(parseTimeUnit(unit.get())); } else { return optional<TimeUnit>(boost::none); @@ -275,8 +279,8 @@ DocumentSourceInternalDensify::DocGenerator::DocGenerator(DensifyValue min, // Extra checks for date step + unit. tassert(5733501, "Unit must be specified with a date step", _range.getUnit()); tassert(5733505, - "Step must be representable as an integer for date densification", - _range.getStep().integral()); + "Step must be a whole number for date densification", + _range.getStep().integral64Bit()); } else { tassert(5733506, "Unit must not be specified with non-date values", !_range.getUnit()); } @@ -877,7 +881,7 @@ DensifyValue DensifyValue::increment(const RangeStatement& range) const { }, [&](Date_t date) { return DensifyValue(dateAdd( - date, range.getUnit().value(), range.getStep().getDouble(), timezone())); + date, range.getUnit().value(), range.getStep().coerceToLong(), timezone())); }}, _value); } @@ -891,7 +895,7 @@ DensifyValue DensifyValue::decrement(const RangeStatement& range) const { }, [&](Date_t date) { return DensifyValue(dateAdd( - date, range.getUnit().value(), -range.getStep().getDouble(), timezone())); + date, range.getUnit().value(), -range.getStep().coerceToLong(), timezone())); }}, _value); } @@ -906,7 +910,7 @@ bool DensifyValue::isOnStepRelativeTo(DensifyValue base, RangeStatement range) c }, [&](Date_t date) { auto unit = range.getUnit().value(); - double step = range.getStep().getDouble(); + long long step = range.getStep().coerceToLong(); auto baseDate = base.getDate(); // Months, quarters and years have variable lengths depending on leap days |