test/functional/streamer.rb in mosql-0.4.1 vs test/functional/streamer.rb in mosql-0.4.2
- old
+ new
@@ -137,9 +137,24 @@
'o' => { '$set' => { 'var' => 100 } },
})
assert_equal(100, sequel[:sqltable].where(:_id => o['_id'].to_s).select.first[:var])
end
+ it 'handle "u" ops with $set, BSON::ObjectID, and a deleted row' do
+ o = { '_id' => BSON::ObjectId.new, 'var' => 17 }
+ @adapter.upsert_ns('mosql_test.collection', o)
+
+ # Don't store the row in mongo, which will cause the 'u' op to
+ # delete it from SQL.
+
+ @streamer.handle_op({ 'ns' => 'mosql_test.collection',
+ 'op' => 'u',
+ 'o2' => { '_id' => o['_id'] },
+ 'o' => { '$set' => { 'var' => 100 } },
+ })
+ assert_equal(0, sequel[:sqltable].count(:_id => o['_id'].to_s))
+ end
+
it 'handle "u" ops with $set and a renamed _id' do
o = { '_id' => BSON::ObjectId.new, 'goats' => 96 }
@adapter.upsert_ns('mosql_test.renameid', o)
# $set's are currently a bit of a hack where we read the object