From ca6e7f71da7ed23aa723adb6611bf1fbb06e2137 Mon Sep 17 00:00:00 2001 From: Martin Little Date: Mon, 16 May 2011 09:24:04 -0400 Subject: Added a basic test for the informix visitor --- lib/arel/visitors.rb | 2 ++ test/visitors/test_informix.rb | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/visitors/test_informix.rb diff --git a/lib/arel/visitors.rb b/lib/arel/visitors.rb index f2644d7205..8276eace2b 100644 --- a/lib/arel/visitors.rb +++ b/lib/arel/visitors.rb @@ -11,6 +11,7 @@ require 'arel/visitors/where_sql' require 'arel/visitors/order_clauses' require 'arel/visitors/dot' require 'arel/visitors/ibm_db' +require 'arel/visitors/informix' module Arel module Visitors @@ -24,6 +25,7 @@ module Arel 'sqlite' => Arel::Visitors::SQLite, 'sqlite3' => Arel::Visitors::SQLite, 'ibm_db' => Arel::Visitors::IBM_DB, + 'informix' => Arel::Visitors::Informix, } ENGINE_VISITORS = Hash.new do |hash, engine| diff --git a/test/visitors/test_informix.rb b/test/visitors/test_informix.rb new file mode 100644 index 0000000000..db5e52b8a4 --- /dev/null +++ b/test/visitors/test_informix.rb @@ -0,0 +1,34 @@ +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 + + end + end +end -- cgit v1.2.3