diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-09-27 16:10:35 -0400 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2017-10-02 12:04:47 -0400 |
commit | ee6b784fecd5a8e8717a7a17a78a0d54535c5df7 (patch) | |
tree | 206b319ca42be531a0c1c51a09c1887bcc2c833e /src/mongo | |
parent | 113b4fa007f638675586203fb5a9e735bcff36f5 (diff) | |
download | mongo-ee6b784fecd5a8e8717a7a17a78a0d54535c5df7.tar.gz |
SERVER-23410 Include millis and 'Z' when converting agg dates to strings
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/pipeline/document_value_test.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/pipeline/expression_test.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/pipeline/value.cpp | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/document_value_test.cpp b/src/mongo/db/pipeline/document_value_test.cpp index 34f993f1180..613ec1de0d1 100644 --- a/src/mongo/db/pipeline/document_value_test.cpp +++ b/src/mongo/db/pipeline/document_value_test.cpp @@ -1375,10 +1375,10 @@ class TimestampToString : public ToStringBase { /** Coerce date to string. */ class DateToString : public ToStringBase { Value value() { - return Value(Date_t::fromMillisSinceEpoch(1234567890LL * 1000)); + return Value(Date_t::fromMillisSinceEpoch(1234567890123LL)); } string expected() { - return "2009-02-13T23:31:30"; + return "2009-02-13T23:31:30.123Z"; } // from js }; diff --git a/src/mongo/db/pipeline/expression_test.cpp b/src/mongo/db/pipeline/expression_test.cpp index 048dcbe769d..5dbd9ad12ee 100644 --- a/src/mongo/db/pipeline/expression_test.cpp +++ b/src/mongo/db/pipeline/expression_test.cpp @@ -3867,6 +3867,15 @@ TEST(ExpressionSubstrCPTest, WithMixedUnicodeAndASCIIValue) { {{{Value("a∫bøßabc"_sd), Value(1), Value(4)}, Value("∫b"_sd)}}); } +TEST(ExpressionSubstrCPTest, ShouldCoerceDateToString) { + assertExpectedResults("$substrCP", + {{{Value(Date_t::fromMillisSinceEpoch(0)), Value(0), Value(1000)}, + Value("1970-01-01T00:00:00.000Z"_sd)}}); + assertExpectedResults("$substrBytes", + {{{Value(Date_t::fromMillisSinceEpoch(0)), Value(0), Value(1000)}, + Value("1970-01-01T00:00:00.000Z"_sd)}}); +} + } // namespace SubstrCP namespace Type { diff --git a/src/mongo/db/pipeline/value.cpp b/src/mongo/db/pipeline/value.cpp index 2695da381d0..62e64c731e4 100644 --- a/src/mongo/db/pipeline/value.cpp +++ b/src/mongo/db/pipeline/value.cpp @@ -57,7 +57,7 @@ using std::stringstream; using std::vector; namespace { -constexpr StringData kISOFormatString = "%Y-%m-%dT%H:%M:%S"_sd; +constexpr StringData kISOFormatString = "%Y-%m-%dT%H:%M:%S.%LZ"_sd; } void ValueStorage::verifyRefCountingIfShould() const { |