
attribute.in => array should not change the array
Reported by Michal Hantl | January 5th, 2010 @ 04:29 PM
class DmTest < Test::Unit::TestCase
def test_in_doesnt_change_its_parameter
ids = [1,2,2]
Node.all(:id.in => ids)
assert_equal [1,2,2], ids # fail, because now ids == [1,2]
end end
Comments and changes to this ticket
-
Dan Kubb (dkubb) February 5th, 2010 @ 03:01 AM
- State changed from new to unconfirmed
Can you provide a stand-alone script that reproduces this problem?
-
Michal Hantl February 5th, 2010 @ 04:16 AM
I almost did, are you unable to recreate it?
You should need to add something like following
class Node include DataMapper::Resource end class DmTest < Test::Unit::TestCase def test_in_doesnt_change_its_parameter ids = [1,2,2] Node.all(:id.in => ids) assert_equal [1,2,2], ids # fail, because now ids == [1,2] end end
-
Piotr Solnica (solnic) February 5th, 2010 @ 05:21 AM
It doesn't change the array in a way that would lead to an incorrect query. You get an array with unique values - I think that's a good behavior.
[edit] Oh I see your point, the local variable gets changed, sorry I missed that when I first looked at the ticket :) - I just ran the test against dm 0.10.3 and the problem is fixed.
-
Piotr Solnica (solnic) February 5th, 2010 @ 05:26 AM
- State changed from unconfirmed to resolved
-
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »