Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-32861

Aggregation coercion to bool should not consider the empty string as true

    XMLWordPrintableJSON

Details

    • Query Optimization

    Description

      When used in a boolean concept, all strings are considered to be truthy. For example:

      > db.foo.aggregate([{$project: {x: {$cond: {if: "", then: "hi", else: "bye"}}}}])
      { "_id" : ObjectId("5a31839ba9fb0c07a00ff123"), "x" : "hi" }
      

      Most programming languages treat the empty string as "falsey". I think it would be less confusing for our users if we do the same.

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: