Files
mongo/jstests/aggregation/sources/project/analyze_deps_string_order.js
Mihai Andrei 1a8480a015 SERVER-95514 Assign more narrow ownership to files under 'jstests/aggregation' (#30660)
GitOrigin-RevId: 494c0fdfadd2f8986333dbf4242462d576439c4b
2025-01-22 20:14:44 +00:00

34 lines
913 B
JavaScript

// SERVER-66418
// Bad projection created during dependency analysis due to string order assumption
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"]}
}
}
}
}
]);