mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
stop using deprecated AND usage
This commit is contained in:
parent
11e29a32af
commit
6be1a71464
3 changed files with 16 additions and 6 deletions
|
@ -36,9 +36,9 @@ module Arel
|
||||||
if other.exclude_end?
|
if other.exclude_end?
|
||||||
left = Nodes::GreaterThanOrEqual.new(self, other.begin)
|
left = Nodes::GreaterThanOrEqual.new(self, other.begin)
|
||||||
right = Nodes::LessThan.new(self, other.end)
|
right = Nodes::LessThan.new(self, other.end)
|
||||||
Nodes::And.new left, right
|
Nodes::And.new [left, right]
|
||||||
else
|
else
|
||||||
Nodes::Between.new(self, Nodes::And.new(other.begin, other.end))
|
Nodes::Between.new(self, Nodes::And.new([other.begin, other.end]))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Nodes::In.new self, other
|
Nodes::In.new self, other
|
||||||
|
@ -174,7 +174,7 @@ module Arel
|
||||||
first = send method_id, others.shift
|
first = send method_id, others.shift
|
||||||
|
|
||||||
Nodes::Grouping.new others.inject(first) { |memo,expr|
|
Nodes::Grouping.new others.inject(first) { |memo,expr|
|
||||||
Nodes::And.new(memo, send(method_id, expr))
|
Nodes::And.new([memo, send(method_id, expr)])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,7 +78,6 @@ module Arel
|
||||||
end
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
Arel::Nodes::And,
|
|
||||||
Arel::Nodes::Assignment,
|
Arel::Nodes::Assignment,
|
||||||
Arel::Nodes::Between,
|
Arel::Nodes::Between,
|
||||||
Arel::Nodes::DoesNotMatch,
|
Arel::Nodes::DoesNotMatch,
|
||||||
|
@ -106,6 +105,17 @@ module Arel
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# N-ary
|
||||||
|
[
|
||||||
|
Arel::Nodes::And,
|
||||||
|
].each do |klass|
|
||||||
|
define_method("test_#{klass.name.gsub('::', '_')}") do
|
||||||
|
binary = klass.new([:a, :b])
|
||||||
|
@visitor.accept binary
|
||||||
|
assert_equal [:a, :b, binary], @collector.calls
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
Arel::Attributes::Integer,
|
Arel::Attributes::Integer,
|
||||||
Arel::Attributes::Float,
|
Arel::Attributes::Float,
|
||||||
|
|
|
@ -50,7 +50,7 @@ module Arel
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should apply Not to the whole expression" do
|
it "should apply Not to the whole expression" do
|
||||||
node = Nodes::And.new @attr.eq(10), @attr.eq(11)
|
node = Nodes::And.new [@attr.eq(10), @attr.eq(11)]
|
||||||
sql = @visitor.accept Nodes::Not.new(node)
|
sql = @visitor.accept Nodes::Not.new(node)
|
||||||
sql.must_be_like %{NOT ("users"."id" = 10 AND "users"."id" = 11)}
|
sql.must_be_like %{NOT ("users"."id" = 10 AND "users"."id" = 11)}
|
||||||
end
|
end
|
||||||
|
@ -82,7 +82,7 @@ module Arel
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should visit_Arel_Nodes_And" do
|
it "should visit_Arel_Nodes_And" do
|
||||||
node = Nodes::And.new @attr.eq(10), @attr.eq(11)
|
node = Nodes::And.new [@attr.eq(10), @attr.eq(11)]
|
||||||
@visitor.accept(node).must_be_like %{
|
@visitor.accept(node).must_be_like %{
|
||||||
"users"."id" = 10 AND "users"."id" = 11
|
"users"."id" = 10 AND "users"."id" = 11
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue