aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-10-23 14:53:20 -0600
committerSean Griffin <sean@thoughtbot.com>2014-10-24 09:01:39 -0500
commit51f48f0ed9ec84fd12584b750609a2f7e945b945 (patch)
treefba26fe05d08294f4e08502cea32650aeede5220 /test
parent0e6c7e6de73fdddaf7f1486657f4d9f8e8f5fde3 (diff)
downloadrails-51f48f0ed9ec84fd12584b750609a2f7e945b945.tar.gz
rails-51f48f0ed9ec84fd12584b750609a2f7e945b945.tar.bz2
rails-51f48f0ed9ec84fd12584b750609a2f7e945b945.zip
`#not_in` with a range should respect proper precedence
Currently, doing ```ruby relation[:id].not_eq(4).and(relation[:id].not_in(1..3)) ``` will generate ```sql "id" != 4 AND "id" < 1 OR "id" > 3 ``` Which would incorrectly include records with an id of 4, as the OR statement has higher precidence than the AND statement. The `or` method on `Node` properly groups the statement in parenthesis.
Diffstat (limited to 'test')
-rw-r--r--test/visitors/test_to_sql.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb
index abd8cfe356..62e1c57c73 100644
--- a/test/visitors/test_to_sql.rb
+++ b/test/visitors/test_to_sql.rb
@@ -480,16 +480,16 @@ module Arel
it 'can handle two dot ranges' do
node = @attr.not_in 1..3
- compile(node).must_be_like %{
- "users"."id" < 1 OR "users"."id" > 3
- }
+ compile(node).must_equal(
+ %{("users"."id" < 1 OR "users"."id" > 3)}
+ )
end
it 'can handle three dot ranges' do
node = @attr.not_in 1...3
- compile(node).must_be_like %{
- "users"."id" < 1 OR "users"."id" >= 3
- }
+ compile(node).must_equal(
+ %{("users"."id" < 1 OR "users"."id" >= 3)}
+ )
end
it 'can handle ranges bounded by infinity' do