moped icon indicating copy to clipboard operation
moped copied to clipboard

Duplicated key when inserting with string and symbol.

Open magania opened this issue 10 years ago • 1 comments

When inserting into mongo a duplicated key with the same name but one as string and the other as a symbol, It generates a duplicated key in mongo with a wired behavior for the assignment.

The following code,

require 'moped'
require 'bson'

session = Moped::Session.new([ "localhost:27017" ])
session.use('test')

session['test'].insert({ 'a' => 1, b: 2, a: 2 })

generate this in mongo:

{ "_id" : ObjectId("54455288f1aa7bbc3271c0ab"), "a" : 1, "b" : 2, "a" : 1 }

magania avatar Oct 20 '14 18:10 magania

see: https://github.com/mongoid/moped/issues/282

also see: https://jira.mongodb.org/browse/RUBY-761

mclaugsf avatar Oct 30 '14 20:10 mclaugsf