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

Inconsistent rule for storing dotted field names

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.3.6
    • Fix Version/s: 3.6.0-rc1
    • Component/s: Sharding, Storage
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Query 2017-10-23

      Description

      It looks like _id field has stricter rules than other fields:

      > db.getMongo()._skipValidation = true
      true
      > db.user.insert({ x: { 'a.b': 1 }})
      WriteResult({ "nInserted" : 1 })
      > db.user.find()
      { "_id" : ObjectId("573a41831b3dd58ca2e7f085"), "x" : { "a.b" : 1 } }
      > db.user.insert({ _id: { 'a.b': 1 }})
      WriteResult({
      	"nInserted" : 0,
      	"writeError" : {
      		"code" : 57,
      		"errmsg" : "a.b is not valid for storage."
      	}
      })
      

      In more detail, the dotted field names is currently disallowed in:

      • top level fields
      • any level inside _id

      and is allowed any other place

      Also note that mongos is already relying on this behavior:

      mongos> db.adminCommand({ enableSharding: 'test' })
      { "ok" : 1 }
      mongos> db.adminCommand({ shardCollection: 'test.user', key: { 'x.y': 1 }})
      { "collectionsharded" : "test.user", "ok" : 1 }
      mongos> use config
      switched to db config
      mongos> db.chunks.find()
      { "_id" : "test.user-x.y_MinKey", "ns" : "test.user", "min" : { "x.y" : { "$minKey" : 1 } }, "max" : { "x.y" : { "$maxKey" : 1 } }, "shard" : "shard0000", "lastmod" : Timestamp(1, 0), "lastmodEpoch" : ObjectId("573a41e5741a236015ac3ec9") }
      mongos> db.collections.find()
      { "_id" : "test.user", "lastmodEpoch" : ObjectId("573a41e5741a236015ac3ec9"), "lastmod" : ISODate("1970-02-19T17:02:47.296Z"), "dropped" : false, "key" : { "x.y" : 1 }, "unique" : false }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              nicholas.zolnierz Nicholas Zolnierz
              Reporter:
              renctan Randolph Tan
              Participants:
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: