-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:MongoDB 0.9.1, mongo-activerecord-ruby git version 0abf50167616ad627460e633539d321c520409ac
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When using the MongoRecord framework changes to existing documents (with the save method) insert a new document into MongoDB rather than updating the existing document as would be expected.
Some code that demonstrates this issue is as follows:
class Test < MongoRecord::Base
fields :name, :data
collection_name 'test'
end
Test.delete_all({})
t1 = Test.new({:name => 'test', :data => 'first'})
t1.save
t1.data = 'second'
t1.save
t2 = Test.find(:first, :conditions => {:name => 'test'})
t2.data = 'third'
t2.save
results = Test.find(:all)
results.each do |row|
p row
end