Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
3.2.9
-
None
-
ALL
-
Description
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... ?!
Attachments
Issue Links
- duplicates
-
SERVER-13903 inconsistent treatment of null in $project comparisons vs other stages
-
- Backlog
-