mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
quoting limit nodes
This commit is contained in:
parent
c28fe4cbbb
commit
4010568595
6 changed files with 23 additions and 3 deletions
|
@ -25,7 +25,7 @@ module Arel
|
|||
("SET #{o.values.map { |value| visit value }.join ', '}" unless o.values.empty?),
|
||||
("WHERE #{o.wheres.map { |x| visit x }.join ' AND '}" unless o.wheres.empty?),
|
||||
("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?),
|
||||
("LIMIT #{o.limit}" if o.limit),
|
||||
("LIMIT #{visit o.limit}" if o.limit),
|
||||
].compact.join ' '
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Arel
|
|||
[
|
||||
"SELECT * FROM (#{sql}) AS id_list",
|
||||
"ORDER BY #{aliased_orders(o.orders).join(', ')}",
|
||||
("LIMIT #{o.limit}" if o.limit),
|
||||
("LIMIT #{visit o.limit}" if o.limit),
|
||||
(visit(o.offset) if o.offset),
|
||||
].compact.join ' '
|
||||
else
|
||||
|
|
|
@ -76,7 +76,7 @@ module Arel
|
|||
[
|
||||
o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join,
|
||||
("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?),
|
||||
("LIMIT #{o.limit}" if o.limit),
|
||||
("LIMIT #{visit o.limit}" if o.limit),
|
||||
(visit(o.offset) if o.offset),
|
||||
(visit(o.lock) if o.lock),
|
||||
].compact.join ' '
|
||||
|
|
|
@ -17,6 +17,12 @@ module Arel
|
|||
sql.must_be_like "SELECT FROM DUAL LIMIT 18446744073709551615 OFFSET 1"
|
||||
end
|
||||
|
||||
it "should escape LIMIT" do
|
||||
sc = Arel::Nodes::UpdateStatement.new
|
||||
sc.limit = "omg"
|
||||
assert_match(/LIMIT 'omg'/, @visitor.accept(sc))
|
||||
end
|
||||
|
||||
it 'uses DUAL for empty from' do
|
||||
stmt = Nodes::SelectStatement.new
|
||||
sql = @visitor.accept(stmt)
|
||||
|
|
|
@ -12,6 +12,14 @@ module Arel
|
|||
FOR UPDATE
|
||||
}
|
||||
end
|
||||
|
||||
it "should escape LIMIT" do
|
||||
sc = Arel::Nodes::SelectStatement.new
|
||||
sc.limit = "omg"
|
||||
sc.cores.first.projections << 'DISTINCT ON'
|
||||
sc.orders << "xyz"
|
||||
assert_match(/LIMIT 'omg'/, @visitor.accept(sc))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,6 +30,12 @@ module Arel
|
|||
@visitor.accept(DateTime).must_equal "'DateTime'"
|
||||
end
|
||||
|
||||
it "should escape LIMIT" do
|
||||
sc = Arel::Nodes::SelectStatement.new
|
||||
sc.limit = "omg"
|
||||
assert_match(/LIMIT 'omg'/, @visitor.accept(sc))
|
||||
end
|
||||
|
||||
it "should visit_DateTime" do
|
||||
@visitor.accept DateTime.now
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue