Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5064

and in expr on nonexisting field always returns "true"

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Query
    • None

       

      Running this query on any collection:

      {non_existing_field: {$ne: null}}
      

      will return no objects, since 

      The \{ item : null } query matches documents that either contain the item field whose value is null or that do not contain the item field
      

      However, running

      {$expr: {$and: [
                    {
                    $ne: [
                      non_existing_field, null
                    ]
                  }
        ]}}
      

      Returns all the fields from the collection- seems like it always returns true.

            Assignee:
            alex.bevilacqua@mongodb.com Alex Bevilacqua
            Reporter:
            mginszt@redhat.com Marcin Ginszt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: