Sha256: e43a79a8dc55ce630e7c7614e667ca6f1430f1343e55651da900463639f214a4

Contents?: true

Size: 1.5 KB

Versions: 19

Compression:

Stored size: 1.5 KB

Contents

require 'helper'

module Arel
  module Visitors
    describe 'the informix visitor' do
      before do
        @visitor = Informix.new Table.engine.connection
      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

      it 'uses INNER JOIN to perform joins' do
        core = Nodes::SelectCore.new
        table = Table.new(:posts)
        core.source = Nodes::JoinSource.new(table, [table.create_join(Table.new(:comments))])

        stmt = Nodes::SelectStatement.new([core])
        sql = @visitor.accept(stmt)
        sql.must_be_like 'SELECT FROM "posts" INNER JOIN "comments"'
      end

    end
  end
end

Version data entries

19 entries across 14 versions & 5 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/arel-3.0.3/test/visitors/test_informix.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/test/visitors/test_informix.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/test/visitors/test_informix.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/test/visitors/test_informix.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/arel-3.0.3/test/visitors/test_informix.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/arel-3.0.3/test/visitors/test_informix.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/arel-3.0.3/test/visitors/test_informix.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/arel-3.0.3/test/visitors/test_informix.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/arel-3.0.3/test/visitors/test_informix.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/arel-3.0.3/test/visitors/test_informix.rb
arel-5.0.1.20140414130214 test/visitors/test_informix.rb
arel-4.0.2 test/visitors/test_informix.rb
arel-5.0.0 test/visitors/test_informix.rb
arel-3.0.3 test/visitors/test_informix.rb
arel-4.0.1 test/visitors/test_informix.rb
challah-1.0.0 vendor/bundle/gems/arel-4.0.0/test/visitors/test_informix.rb
arel-4.0.0 test/visitors/test_informix.rb
arel-4.0.0.beta2 test/visitors/test_informix.rb
arel-4.0.0.beta1 test/visitors/test_informix.rb