Files
mongo/jstests/aggregation/sources/project/analyze_deps_string_order.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

37 lines
980 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"]},
},
},
},
},
]);