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

The existence of index affects the type of projection field.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 3.4.10
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Environment:
      Windows 2012 (64 bit), windows 7 sp1 (64 bit)
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      Unzip the appTasks.zip -> appTasks.json
      Import the appTasks.json file:

      mongoimport -h localhost:27017 -u <user> -p <password> --authenticationDatabase <db> -d test -c appTasks --drop --file appTasks.json
      

      Enter the data base with mongo shell.

      run the query:

      db.appTasks.find({ "taskState" : 1, "isFolderLocking" : true, "affectedFolders" : { "$in" : [NumberLong("1000000000000114891")] } },{"affectedFolders":1, "_id":0})
      

      The result is:

      { "affectedFolders" : [ NumberLong("1000000000000114891") ] }
      

      This result is correct because the field 'affectedFolders' is an array of int64.

      create the following index:

      db.appTasks.createIndex({"taskState":1, "isFolderLocking":1, "affectedFolders":1})
      

      run the query again:

      db.appTasks.createIndex({"taskState":1, "isFolderLocking":1, "affectedFolders":1})
      

      The result is:

      { "affectedFolders" : NumberLong("1000000000000114891") }
      

      This result is incorrect because the returned type is int64 instead of an array of int64.

      Show
      Unzip the appTasks.zip -> appTasks.json Import the appTasks.json file: mongoimport -h localhost:27017 -u <user> -p <password> --authenticationDatabase <db> -d test -c appTasks --drop --file appTasks.json Enter the data base with mongo shell. run the query: db.appTasks.find({ "taskState" : 1, "isFolderLocking" : true, "affectedFolders" : { "$in" : [NumberLong("1000000000000114891")] } },{"affectedFolders":1, "_id":0}) The result is: { "affectedFolders" : [ NumberLong("1000000000000114891") ] } This result is correct because the field 'affectedFolders' is an array of int64. create the following index: db.appTasks.createIndex({"taskState":1, "isFolderLocking":1, "affectedFolders":1}) run the query again: db.appTasks.createIndex({"taskState":1, "isFolderLocking":1, "affectedFolders":1}) The result is: { "affectedFolders" : NumberLong("1000000000000114891") } This result is incorrect because the returned type is int64 instead of an array of int64.

      Description

      A field that is an array of int64 is projected as int64 if an index that include the field exists.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mark.agarunov Mark Agarunov
              Reporter:
              itzikkg Itzhak Kagan
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: