Changeset [5439380b60875401f89405aea98cfde9d267eb10] by Dan Kubb

June 6th, 2012 @ 07:07 PM

Update :in comparison to handle nil values mixed into normal values

  • In DataMapper the assumption is that the following is always true:

    Model.all == Model.all(:name => value) | Model.all(:name.not => value)

The previous code would not work properly if nil values were mixed in with normal values. It would've created a clause like:

WHERE name IN(NULL, 'Dan')

Which only works if name can never be NULL. If it can, then those will be excluded from the results. What you want to generate is:

WHERE name IN('Dan') OR name IS NULL

If the above is negated, then the following can be generated:

WHERE NOT(name IN('Dan') OR name IS NULL)

The union of these two queries should equal the original rows.

Committed by Dan Kubb

  • M dm-do-adapter.gemspec
  • M lib/dm-do-adapter/adapter.rb
  • M lib/dm-do-adapter/spec/shared_spec.rb
New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »