diff options
Diffstat (limited to 'jstests/aggregation/bugs/server66418.js')
-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"]} + } + } + } + } +]); +})(); |