aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/visitors/test_informix.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/visitors/test_informix.rb b/test/visitors/test_informix.rb
new file mode 100644
index 0000000000..a8a52a0160
--- /dev/null
+++ b/test/visitors/test_informix.rb
@@ -0,0 +1,42 @@
+require 'helper'
+
+module Arel
+ module Visitors
+ describe 'the informix visitor' do
+ before do
+ @visitor = Informix.new Table.engine
+ end
+
+ it 'uses LIMIT n to limit results' do
+ stmt = Nodes::SelectStatement.new
+ stmt.limit = Nodes::Limit.new(1)
+ sql = @visitor.accept(stmt)
+ sql.must_be_like "SELECT LIMIT 1"
+ end
+
+ it 'uses LIMIT n 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 LIMIT 1 'id')"
+ end
+
+ it 'uses SKIP n to jump results' do
+ stmt = Nodes::SelectStatement.new
+ stmt.offset = Nodes::Offset.new(10)
+ sql = @visitor.accept(stmt)
+ sql.must_be_like "SELECT SKIP 10"
+ end
+
+ it 'uses SKIP before LIMIT' do
+ stmt = Nodes::SelectStatement.new
+ stmt.limit = Nodes::Limit.new(1)
+ stmt.offset = Nodes::Offset.new(1)
+ sql = @visitor.accept(stmt)
+ sql.must_be_like "SELECT SKIP 1 LIMIT 1"
+ end
+
+ end
+ end
+end