locomotivecms/custom_fields — pull request #32 by conroywhitney (2014-12-16 22:53:54+00:00)
Title: Mongo 2.6 $unset error while pushing wagon

Thank you for all of your work on LocomotiveCMS!

I ran into this error when running `wagon push` to an environment using Mongo 2.6.x:

`{"error"=>"The operation: #1, :safe=>true}\n @fields=nil>\nfailed with error 9: \"'$unset' is empty. You must specify a field like so: {$mod: {: ...}}\"\n\nSee https://github.com/mongodb/mongo/blob/master/docs/errors.md\nfor details about this error."}`

Looking at the [mongodb-user Google Group](https://groups.google.com/forum/#!topic/mongodb-user/OLCofnfZu4M), it seems this is due to a newly introduced validation in Mongo 2.6 that some people are arguing is unnecessarily strict.

I see #31 which split the $set, $unset, and $rename into separate operations. However, this means it will execute each of those even if there was not originally that command. This patch only executes operations which do not have null or empty-hash values.

I do not claim this is the best solution, but it fixed my issue with `wagon push`!

P.S. For anyone using Heroku, the MongoLab AddOn uses Mongo 2.6.x for free-tier accounts.