diff options
author | Steve Tarzia <steve.tarzia@mongodb.com> | 2022-06-23 22:08:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-23 22:31:56 +0000 |
commit | bd7423724f1cd2983ffa177e2ba538859ae4ff63 (patch) | |
tree | 185e870dd67dad96938f8ce1d94a187568a75b3c /jstests | |
parent | ead0d926edbbcbb795776a2f05f8e4245920c8ff (diff) | |
download | mongo-bd7423724f1cd2983ffa177e2ba538859ae4ff63.tar.gz |
SERVER-66418 fix bug in projection created during dependency analysis
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/aggregation/bugs/server66418.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/jstests/aggregation/bugs/server66418.js b/jstests/aggregation/bugs/server66418.js new file mode 100644 index 00000000000..9b8c960282a --- /dev/null +++ b/jstests/aggregation/bugs/server66418.js @@ -0,0 +1,38 @@ +// SERVER-66418 +// Bad projection created during dependency analysis due to string order assumption +(function() { +"use strict"; + +const coll = db[jsTest.name()]; +coll.drop(); + +coll.save({ + _id: 1, + type: 'PRODUCT', + status: 'VALID', + locale: { + en: 'INSTRUMENT PANEL', + es: 'INSTRUMENTOS DEL CUADRO', + fr: 'INSTRUMENT TABLEAU DE BORD', + } +}); + +// before SERVER-66418, this incorrectly threw a PathCollision error +coll.aggregate([ + {"$match": {"_id": 1}}, + {"$sort": {"_id": 1}}, + { + "$project": { + "designation": { + "$switch": { + "branches": [{ + "case": {"$eq": ["$type", "PRODUCT"]}, + "then": {"$ifNull": ["$locale.en-GB.name", "$locale.en.name"]} + }], + "default": {"$ifNull": ["$locale.en-GB", "$locale.en"]} + } + } + } + } +]); +})(); |