Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
-
ALL
Description
An object or string specified as a constant to an ExpressionNary may not be parsed as a constant on a shard. This is because ExpressionNary does not use requireExpression with addToBsonArray, so constants are not represented using $const.
Test
// Set up a sharding test.
|
s = new ShardingTest( "aggregation", 2, 0, 2 );
|
s.adminCommand( { enablesharding:"test" } );
|
s.adminCommand( { shardcollection:"test.data", key:{ _id:1 } } );
|
s.stopBalancer()
|
|
|
d = s.getDB( "test" );
|
d.data.save( { dollar:false } );
|
|
|
// Currently the shard will get $cond:[ '$dollar', '$1.00', '$.99' ] and treat the second and third arguments as field paths.
|
result = d.data.aggregate( { $project:{ _id:0, cost:{ $cond:[ '$dollar', { $const:'$1.00' }, { $const:'$.99' } ] } } } );
|
|
|
printjson( result );
|
assert.eq( [ { cost:'$.99' } ], result.result );
|
|
|
s.stop();
|
When fixing this we should also do a general audit for other cases that do not serialize properly.