Skip to content

Keys with the same name #30

Open
Open
@kishlaya

Description

Apparently, I can construct a document in MongoDB like,

{
    "title" : "mytitle",
    "somekey" : {
            "someotherkey" : "somedatahere"
    },
    "somekey" : {
            "someotherkey" : "someotherdatahere"
    }
}

Now, when I query this document in Julia, using for doc in find(collection, query()) println(doc) end it returns me -

BSONObject({ "_id" : { "$oid" : "5b2c99fe3d6c3f8629771362" }, "title" : "mytitle", "somekey" : { "someotherkey" : "somedatahere" }, "somekey" : { "someotherkey" : "someotherdatahere" } })

But if ask for doc["somekey"] then it only returns me contents of first somekey.

I agree, that having keys with same name is not quite appropriate but I think it should have been either:

  • LibBSON had a way to access contents from both the keys directly (without iterating over the entire object and then matching the key names)
  • Or otherwise, LibBSON threw an error (or some warning maybe?) about duplicate keys.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions