Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug in Modifiers assumes _id is ObjectId #456

Closed
jamieorc opened this Issue · 6 comments

2 participants

@jamieorc

Please see commit 39321c8 by Haris Amin. The code changes in criteria_and_keys_from_args(args) in modifiers.rb assumes that the _id is a BSON ObjectId. As MongoDB does not require the _id to be a BSON::ObjectId, unnecessarily restricts the _id type and is a breaking change.

I and others have _ids that are not ObjectIds. MM should never assume that an _id is an ObjectId, as MongoDB does not make this requirement.

I have a very large app with several collections built around Strings for _id--and for very good reasons.

@jnunemaker
Owner

I just pulled something to fix instance modifiers (see unset and company). For the class level ones, if you pass a hash, it should just use that as the criteria. You can easily do {:_id => 'my string id'}, right? Or maybe I'm misunderstanding.

@jamieorc
@jnunemaker
Owner

So this can be closed as a duplicate since it is fixed in master? New release should go out soon. I was trying to get travis to pass and it just won't.

@jnunemaker jnunemaker closed this
@jamieorc

I'm looking at master and it's not fixed:

split_args = args.partition{|a| a.is_a?(BSON::ObjectId)} on line 83 in criteria_and_keys_from_args(args) in modifiers.rb

@jnunemaker
Owner

Just pass a hash is what I was saying. Sorry if that wasn't clear.

For example: https://github.com/jnunemaker/mongomapper/blob/master/test/functional/test_modifiers.rb#L54

Just change :title to _id and the value to whatever string ids.

@jamieorc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.