aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-12-06 20:26:08 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-12-07 10:48:02 -0800
commit40105685957e377c263cfdd59178d3efc3a64181 (patch)
tree70b54b9f1195589bcf6434e24322d6f64fbb5d90 /test
parentc28fe4cbbb1121394c6bb14403350723f9ecce4c (diff)
downloadrails-40105685957e377c263cfdd59178d3efc3a64181.tar.gz
rails-40105685957e377c263cfdd59178d3efc3a64181.tar.bz2
rails-40105685957e377c263cfdd59178d3efc3a64181.zip
quoting limit nodes
Diffstat (limited to 'test')
-rw-r--r--test/visitors/test_mysql.rb6
-rw-r--r--test/visitors/test_postgres.rb8
-rw-r--r--test/visitors/test_to_sql.rb6
3 files changed, 20 insertions, 0 deletions
diff --git a/test/visitors/test_mysql.rb b/test/visitors/test_mysql.rb
index 8606dc39d4..135348580d 100644
--- a/test/visitors/test_mysql.rb
+++ b/test/visitors/test_mysql.rb
@@ -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)
diff --git a/test/visitors/test_postgres.rb b/test/visitors/test_postgres.rb
index 618745c35d..b98f78ca12 100644
--- a/test/visitors/test_postgres.rb
+++ b/test/visitors/test_postgres.rb
@@ -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
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb
index 5cbaaac501..b9d6c78e62 100644
--- a/test/visitors/test_to_sql.rb
+++ b/test/visitors/test_to_sql.rb
@@ -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