2010-10-18 19:54:50 -04:00
|
|
|
require 'helper'
|
2010-10-18 18:41:21 -04:00
|
|
|
|
2010-08-23 13:14:02 -04:00
|
|
|
module Arel
|
|
|
|
module Nodes
|
|
|
|
describe 'sql literal' do
|
2010-09-28 20:08:28 -04:00
|
|
|
describe 'sql' do
|
|
|
|
it 'makes a sql literal node' do
|
|
|
|
sql = Arel.sql 'foo'
|
2010-10-18 18:41:21 -04:00
|
|
|
sql.must_be_kind_of Arel::Nodes::SqlLiteral
|
2010-09-28 20:08:28 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-08-23 13:14:02 -04:00
|
|
|
describe 'count' do
|
|
|
|
it 'makes a count node' do
|
|
|
|
node = SqlLiteral.new('*').count
|
|
|
|
viz = Visitors::ToSql.new Table.engine
|
2010-10-18 18:41:21 -04:00
|
|
|
viz.accept(node).must_be_like %{ COUNT(*) }
|
2010-08-23 13:14:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'makes a distinct node' do
|
|
|
|
node = SqlLiteral.new('*').count true
|
|
|
|
viz = Visitors::ToSql.new Table.engine
|
2010-10-18 18:41:21 -04:00
|
|
|
viz.accept(node).must_be_like %{ COUNT(DISTINCT *) }
|
2010-08-23 13:14:02 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|