JackAdams / meteor-transactions

App level transactions for Meteor + Mongo
http://transactions.taonova.com/
MIT License
113 stars 16 forks source link

A $set transaction with one new property will create an $unset inverse #50

Closed lynchem closed 8 years ago

lynchem commented 8 years ago

Note sure if this is a known issue but if in a transaction you both create a new property and also update an existing one the inverse will $unset both.

Existing Doc { bar: 5 }

Update { $set: {foo : 5, bar: 3} }

Inverse { $unset: {foo: "", bar: "" } }

If you need a better repro let me know and I'll make one.

JackAdams commented 8 years ago

No, no repro needed. I get exactly what you're talking about. It's almost certainly a bug that needs fixing and I'm pretty sure I know where the guilty bit of code is.

Now, having said that ... if you wanted to write an jasmine server integration test to show this failing ...

;-)

JackAdams commented 8 years ago

Haven't been able to reproduce this exactly. I'm getting this for the inverse: { $set: {foo: "", bar: 5 } } ... which is still problematic and needs fixing. (foo should be unset, not set to an empty string). or, if I reverse, the order of the fields in the update: { '$unset' : { bar: 5, foo: '' } } ... which is also problematic and needs fixing. (bar should not be unset and foo should).

JackAdams commented 8 years ago

0.7.8 fixes this. Tests written and passing.