Du har ret, der er en vis inkonsekvens i MongoDB's oplog-implementering, der tillader et dokumentformat for hver op-log, der teknisk set ikke tillader, at et sådant dokument kan forespørges i overensstemmelse hermed.
Selv at indsætte den samme post er ikke mulig, da den har et $set feltnavn:
db.tmp2.insert({
"ts" : Timestamp(1450117240, 1),
"h" : NumberLong(2523649590228245285),
"v" : NumberInt(2),
"op" : "u",
"ns" : "test.tmp",
"o2" : {
"_id" : ObjectId("566f069e63d6a355b2c446af")
},
"o" : {
"$set" : {
"b.d" : NumberInt(4)
}
}
})
2015-12-14T10:27:04.616-0800 E QUERY Error: field names cannot start with $ [$set]
at Error (<anonymous>)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:161:19)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:165:18)
at insert (src/mongo/shell/bulk_api.js:646:20)
at DBCollection.insert (src/mongo/shell/collection.js:243:18)
at (shell):1:9 at src/mongo/shell/collection.js:161
og b.d er ugyldig for en nøgle
db.tmp.update({ a: 1 }, { $set: { 'b.d': 4 } }, { upsert: true })
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
db.oplog.rs.find()
db.tmp2.insert({
"ts" : Timestamp(1450117240, 1),
"h" : NumberLong(2523649590228245285),
"v" : NumberInt(2),
"op" : "u",
"ns" : "test.tmp",
"o2" : {
"_id" : ObjectId("566f069e63d6a355b2c446af")
},
"o" : {
"set" : {
"b.d" : NumberInt(4)
}
}
})
2015-12-14T10:23:26.491-0800 E QUERY Error: can't have . in field names [b.d]
at Error (<anonymous>)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:157:19)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:165:18)
at DBCollection._validateForStorage (src/mongo/shell/collection.js:165:18)
at insert (src/mongo/shell/bulk_api.js:646:20)
at DBCollection.insert (src/mongo/shell/collection.js:243:18)
at (shell):1:9 at src/mongo/shell/collection.js:157
Måske skal der logges et Jira-problem, der anbefaler, at en syntaks med $set-søgningen skal indstilles som en værdi:
{
"ts" : Timestamp(1450117240, 1),
"h" : NumberLong(2523649590228245285),
"v" : NumberInt(2),
"op" : "u",
"ns" : "test.tmp",
"o2" : {
"_id" : ObjectId("566f069e63d6a355b2c446af")
},
"o" : {
"$set" : {
"key" : "b.d"
"value" : NumberInt(4)
}
}
}
Opdatering:Oprettede et Jira-problem til dette:
https://jira.mongodb.org/browse/SERVER-21889