Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-940

$size with $all doesn't work properly.

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.22
    • Component/s: MongoDB 3.2
    • Labels:
    • Environment:
      Node.js

      Lets say I have the below record in the `Groups` collection:
      ```

      { "_id" : ObjectId("5899aa7cf226640ba4023c8f"), "members" : [ "a", "b" ] }

      ```
      Then if I do query like this, then it works fine:
      ```
      db.Groups.find({
      members:

      { $size: 2, $all: ['a', 'b'] }

      })
      ```

      But if I do query like this:
      ```
      db.Groups.find({
      members:

      { $size: 2, $all: ['b', 'ba] }

      })
      ```
      Then I will get this error, quite surprised:
      ```
      { MongoError: exception: cannot infer query fields to set, path 'members' is matched twice
      at Function.MongoError.create (/app/node_modules/mongodb-core/lib/error.js:31:11)
      at /app/node_modules/mongodb-core/lib/connection/pool.js:483:72
      at authenticateStragglers (/app/node_modules/mongodb-core/lib/connection/pool.js:429:16)
      at Connection.messageHandler (/app/node_modules/mongodb-core/lib/connection/pool.js:463:5)
      at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:319:22)
      at emitOne (events.js:96:13)
      at Socket.emit (events.js:188:7)
      at readableAddChunk (_stream_readable.js:176:18)
      at Socket.Readable.push (_stream_readable.js:134:10)
      at TCP.onread (net.js:548:20)
      name: 'MongoError',
      message: 'exception: cannot infer query fields to set, path \'members\' is matched twice',
      errmsg: 'exception: cannot infer query fields to set, path \'members\' is matched twice',
      code: 54,
      ok: 0,
      '$gleStats':
      { lastOpTime: Timestamp

      { _bsontype: 'Timestamp', low_: 0, high_: 0 }

      ,
      electionId: 589c42b7d4fababa657fa1c2 } }
      ```

            Assignee:
            Unassigned Unassigned
            Reporter:
            lnshi Leonard Shi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: