aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorShane Emmons <semmons99@gmail.com>2011-04-29 10:10:06 -0400
committerShane Emmons <semmons99@gmail.com>2011-04-29 10:10:06 -0400
commitc2e7f36f87184f23e9d83269ff20f99a29ec75ad (patch)
treefe0cd4b5f8e8acacf2a830a0032467c4878852d8 /test
parent909538048e17cea47f5c57f36ca103865ea17353 (diff)
downloadrails-c2e7f36f87184f23e9d83269ff20f99a29ec75ad.tar.gz
rails-c2e7f36f87184f23e9d83269ff20f99a29ec75ad.tar.bz2
rails-c2e7f36f87184f23e9d83269ff20f99a29ec75ad.zip
replace 'LIMIT n' with 'FETCH FIRST n ROWS ONLY' when using ibm_db
Diffstat (limited to 'test')
-rw-r--r--test/visitors/test_ibm_db.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/visitors/test_ibm_db.rb b/test/visitors/test_ibm_db.rb
new file mode 100644
index 0000000000..cc35bb768d
--- /dev/null
+++ b/test/visitors/test_ibm_db.rb
@@ -0,0 +1,27 @@
+require 'helper'
+
+module Arel
+ module Visitors
+ describe 'the ibm_db visitor' do
+ before do
+ @visitor = IBM_DB.new Table.engine
+ end
+
+ it 'uses FETCH FIRST n ROWS to limit results' do
+ stmt = Nodes::SelectStatement.new
+ stmt.limit = Nodes::Limit.new(1)
+ sql = @visitor.accept(stmt)
+ sql.must_be_like "SELECT FETCH FIRST 1 ROWS ONLY"
+ end
+
+ it 'uses FETCH FIRST n ROWS in updates with a limit' do
+ stmt = Nodes::UpdateStatement.new
+ stmt.limit = Nodes::Limit.new(1)
+ stmt.key = 'id'
+ sql = @visitor.accept(stmt)
+ sql.must_be_like "UPDATE NULL WHERE 'id' IN (SELECT 'id' FETCH FIRST 1 ROWS ONLY)"
+ end
+
+ end
+ end
+end