-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.2.9
-
Component/s: Aggregation Framework
-
None
-
ALL
-
here's some data:
> db.scratch.find() { "_id" : ObjectId("57e0bac25e54b80da88af731"), "a" : "baz" } { "_id" : ObjectId("57e0bac75e54b80da88af732"), "a" : "foo", "b" : "bar" }
here's a pipeline, desired effect is to concat a and b if i have both fields, or just use a if b isn't present:
> db.scratch.aggregate([{$project: {ab: {$cond: [{$eq: ['$b', null]}, '$a', {$concat: ['$a', ':', '$b']}]}}}]) { "_id" : ObjectId("57e0bac25e54b80da88af731"), "ab" : null } { "_id" : ObjectId("57e0bac75e54b80da88af732"), "ab" : "foo:bar" }
but when b is not present and i want a i get null... ?!
- duplicates
-
SERVER-13903 inconsistent treatment of null in $project comparisons vs other stages
- Backlog