aboutsummaryrefslogtreecommitdiffstats
path: root/test/visitors/test_sqlite.rb
blob: a9f3501f20198e732973e09d773e9fe9f72b6604 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'helper'

module Arel
  module Visitors
    describe 'the sqlite visitor' do
      before do
        @visitor = SQLite.new Table.engine.connection_pool
      end

      it 'defaults limit to -1' do
        stmt = Nodes::SelectStatement.new
        stmt.offset = Nodes::Offset.new(1)
        sql = @visitor.accept(stmt, Collectors::SQLString.new).value
        sql.must_be_like "SELECT LIMIT -1 OFFSET 1"
      end

      it 'does not support locking' do
        node = Nodes::Lock.new(Arel.sql('FOR UPDATE'))
        assert_equal '', @visitor.accept(node, Collectors::SQLString.new).value
      end

      it 'does not support boolean' do
        node = Nodes::True.new()
        assert_equal '1', @visitor.accept(node, Collectors::SQLString.new).value
        node = Nodes::False.new()
        assert_equal '0', @visitor.accept(node, Collectors::SQLString.new).value
      end
    end
  end
end