-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.1.0
-
Component/s: None
-
None
-
Major Change
I'm preparing to move from Moped to the new official Ruby driver. I've noticed it accidentally introduces new reserved field name: "ok". This line checks if the first document returned from query contains key "ok" and that its value equals 1:
https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/operation/result.rb#L208
You can successfully create documents with that field, but if you set its value to anything other than 1 and later query the collection returning that document as the first result then you get OperationFailure error with a very unhelpful empty message.
Attached are my test scripts. Here's the run log:
mongoid-errors$ruby okey.rb Using Mongoid 5.0.0.rc0 Saved document #<MyDocument _id: 55e21bd24164617255000000, okey: true> Loaded: #<MyDocument _id: 55e21bd24164617255000000, okey: true> mongoid-errors$ruby also-okey.rb Using Mongoid 5.0.0.rc0 Saved document #<MyDocument _id: 55e21bd5416461725a000000, ok: 1> Loaded: #<MyDocument _id: 55e21bd5416461725a000000, ok: 1> mongoid-errors$ruby not-ok.rb Using Mongoid 5.0.0.rc0 Saved document #<MyDocument _id: 55e21bdc416461725f000000, ok: true> Mongo::Error::OperationFailure Operation failed. Here's the useless message: Message here >> << end of message
Please note that MongoDB documentation does not say anything about "ok" field. Here is the section on field name constraints: