提交 13a3f62a 编写于 作者: R Ryuta Kamizono

Fix merging NOT IN clause to behave the same as before

`HomogeneousIn` has changed merging behavior for NOT IN clause from
before. This changes `equality?` to return true only if `type == :in` to
restore the original behavior.
上级 972f22e4
......@@ -21,7 +21,7 @@ def eql?(other)
alias :== :eql?
def equality?
true
type == :in
end
def invert
......
......@@ -88,6 +88,16 @@ def test_merge_or_clause
assert_equal [david, mary], mary_and_bob.merge(david_and_mary, rewhere: true)
end
def test_merge_not_in_clause
david, mary, bob = authors(:david, :mary, :bob)
non_mary_and_bob = Author.where.not(id: [mary, bob])
assert_equal [david], non_mary_and_bob
assert_equal [david], Author.where(id: david).merge(non_mary_and_bob)
assert_equal [], Author.where(id: mary).merge(non_mary_and_bob)
end
def test_relation_merging
devs = Developer.where("salary >= 80000").merge(Developer.limit(2)).merge(Developer.order("id ASC").where("id < 3"))
assert_equal [developers(:david), developers(:jamis)], devs.to_a
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册