diff options
author | Ivan Fefer <ivan.fefer@mongodb.com> | 2022-11-23 12:22:22 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-23 16:21:46 +0000 |
commit | bb0c1608a165ca60c9ec6ded4df9655791b6e16d (patch) | |
tree | 857953e3c6f09677596649f59ede51f30115a286 /jstests | |
parent | fa551f7ae3edddaf540133a546dfbe1001541602 (diff) | |
download | mongo-bb0c1608a165ca60c9ec6ded4df9655791b6e16d.tar.gz |
SERVER-71270 In timeseries collections prevent match pushdown before project that can affect it
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/aggregation/bugs/timeseries_should_not_push_match_before_project.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/jstests/aggregation/bugs/timeseries_should_not_push_match_before_project.js b/jstests/aggregation/bugs/timeseries_should_not_push_match_before_project.js new file mode 100644 index 00000000000..f2465988f0e --- /dev/null +++ b/jstests/aggregation/bugs/timeseries_should_not_push_match_before_project.js @@ -0,0 +1,30 @@ +// Regression test for SERVER-71270. +(function() { +"use strict"; +load('jstests/aggregation/extras/utils.js'); // For assertArrayEq. +const doc = { + _id: 0, + time: new Date('2019-01-18T13:24:15.443Z'), + tag: {}, +}; + +db.ts.drop(); +db.coll.drop(); + +db.createCollection('ts', {timeseries: {timeField: 'time', metaField: 'tag'}}); +db.createCollection('coll'); + +db.ts.insertOne(doc); +db.coll.insertOne(doc); +const pipeline = [ + {$project: {'time': 0}}, + {$match: {'time': {$lte: new Date('2019-02-13T11:36:03.481Z')}}}, +]; + +const ts = db.ts.aggregate(pipeline).toArray(); +const vanilla = db.coll.aggregate(pipeline).toArray(); +assertArrayEq({ + actual: ts, + expected: vanilla, +}); +}()); |