-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 5.0.9
-
Component/s: None
-
None
-
ALL
db.test.insert({ a: 'a' }); db.test.aggregate([{ $addFields: { result: { $getField: { field: { $concat: ['$a', 'a'] }, input: { aa: 1 } } } } }]);
This leads to:
MongoServerError: Invalid $addFields :: caused by :: $getField requires 'field' to evaluate to a constant, but got a non-constant argument
I don't understand why that happens (and believe it's a bug). According to getField's documentation `field` can be any expression that resolves to a string. In my example it is such but it doesn't work.
- is related to
-
SERVER-74371 Support arbitrary expressions for 'field' parameter for $getField
- Closed