summaryrefslogtreecommitdiff
path: root/jstests/aggregation
diff options
context:
space:
mode:
authorJennifer Peshansky <jennifer.peshansky@mongodb.com>2023-02-08 20:14:13 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-23 19:31:52 +0000
commit0c3af04d9406ca435d7b44a79e7cd6051d2a965b (patch)
tree907a162b99ae72b02185b11941b51a233747c085 /jstests/aggregation
parentdf91b297e17b6dfc47da1cd954ebc4fbefb53cc9 (diff)
downloadmongo-0c3af04d9406ca435d7b44a79e7cd6051d2a965b.tar.gz
SERVER-49979 Support $dateToString expression in SBE
Diffstat (limited to 'jstests/aggregation')
-rw-r--r--jstests/aggregation/bugs/server11118.js1
-rw-r--r--jstests/aggregation/expressions/date_to_string.js19
2 files changed, 12 insertions, 8 deletions
diff --git a/jstests/aggregation/bugs/server11118.js b/jstests/aggregation/bugs/server11118.js
index 560389f21e1..98811928881 100644
--- a/jstests/aggregation/bugs/server11118.js
+++ b/jstests/aggregation/bugs/server11118.js
@@ -3,6 +3,7 @@
"use strict";
load('jstests/aggregation/extras/utils.js');
+load("jstests/libs/sbe_assert_error_override.js"); // Override error-code-checking APIs.
const coll = db.server11118;
diff --git a/jstests/aggregation/expressions/date_to_string.js b/jstests/aggregation/expressions/date_to_string.js
index 82738383a94..5ee28732882 100644
--- a/jstests/aggregation/expressions/date_to_string.js
+++ b/jstests/aggregation/expressions/date_to_string.js
@@ -1,4 +1,5 @@
-load("jstests/aggregation/extras/utils.js"); // For assertErrorCode
+load("jstests/aggregation/extras/utils.js"); // For assertErrorCode
+load("jstests/libs/sbe_assert_error_override.js"); // Override error-code-checking APIs.
(function() {
"use strict";
@@ -250,14 +251,13 @@ assert.eq([{_id: 0, date: null}],
}
})
.toArray());
-
/* --------------------------------------------------------------------------------------- */
let pipeline = [
{$project: {date: {$dateToString: {date: new ISODate("2017-01-04T15:08:51.911Z"), format: 5}}}}
];
-assertErrCodeAndErrMsgContains(
- coll, pipeline, 18533, "$dateToString requires that 'format' be a string");
+let res = coll.runCommand("aggregate", {pipeline: pipeline, cursor: {}});
+assert.commandFailedWithCode(res, 18533);
pipeline = [{$project: {date: {$dateToString: {format: "%Y-%m-%d %H:%M:%S", timezone: "$tz"}}}}];
assertErrCodeAndErrMsgContains(coll, pipeline, 18628, "Missing 'date' parameter to $dateToString");
@@ -273,11 +273,12 @@ pipeline = [{
}
}
}];
-assertErrCodeAndErrMsgContains(coll, pipeline, 40517, "timezone must evaluate to a string");
+res = coll.runCommand("aggregate", {pipeline: pipeline, cursor: {}});
+assert.commandFailedWithCode(res, 40517);
pipeline = [{$project: {date: {$dateToString: {format: "%Y-%m-%d %H:%M:%S", date: 42}}}}];
-assertErrCodeAndErrMsgContains(
- coll, pipeline, 16006, "can't convert from BSON type double to Date");
+res = coll.runCommand("aggregate", {pipeline: pipeline, cursor: {}});
+assert.commandFailedWithCode(res, 16006);
pipeline = [{
$project: {
@@ -290,7 +291,9 @@ pipeline = [{
}
}
}];
-assertErrCodeAndErrMsgContains(coll, pipeline, 40485, "unrecognized time zone identifier");
+
+res = coll.runCommand("aggregate", {pipeline: pipeline, cursor: {}});
+assert.commandFailedWithCode(res, 40485);
pipeline = [{
$project: {date: {$dateToString: {date: new ISODate("2017-01-04T15:08:51.911Z"), format: "%"}}}