Add support for $inc modifier #8

merged 2 commits into from Oct 31, 2012


None yet
2 participants

No description provided.

@@ -222,6 +222,8 @@ def apply_update_directive!(directive_key, directive_value, doc)
case directive_key
when '$set'
directive_value.each { |k, v| doc[k] = v }
+ when '$inc'
+ directive_value.each { |k, v| doc[k] += v }

gdb Oct 24, 2012


If the type of doc[k] is off, should raise:

"Mongo::OperationFailure: 10140: Cannot apply $inc modifier to non-number"


gdb Oct 28, 2012


(To be clear, this will currently raise a Type error -- I would instead raise the Mongo::OperationFailure.)

Jennifer Freitag
Raise OperationFailure when $inc is applied to non-numeric fields
In response to feedback from pull request.

I have added a new commit to raise an OperationFailure and a test that indicates the new behavior. Please let me know if I missed anything else. Thanks!

@@ -4,6 +4,7 @@
require File.join(File.dirname(__FILE__), '../../lib/embedded-mongo')
class InterfaceTest < Test::Unit::TestCase
+ include Mongo

gdb Oct 31, 2012


I prefer not to include namespaces when not needed -- it makes the resulting code a lot harder to trace. No worries though; I'll fix it up.


gdb commented Oct 31, 2012

LGTM, thanks!

gdb added a commit that referenced this pull request Oct 31, 2012

Merge pull request #8 from jfreitag/master
Add support for $inc modifier

@gdb gdb merged commit 844456d into gdb:master Oct 31, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment