diff options
Diffstat (limited to 'test/visitors/test_to_sql.rb')
-rw-r--r-- | test/visitors/test_to_sql.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb index 33783f7d23..34ebb2b278 100644 --- a/test/visitors/test_to_sql.rb +++ b/test/visitors/test_to_sql.rb @@ -5,7 +5,14 @@ module Arel describe 'the to_sql visitor' do before do @visitor = ToSql.new Table.engine - @attr = Table.new(:users)[:id] + @table = Table.new(:users) + @attr = @table[:id] + end + + it 'should not quote sql literals' do + node = @table[Arel.star] + sql = @visitor.accept node + sql.must_be_like '"users".*' end describe 'equality' do @@ -50,7 +57,7 @@ module Arel end it "should apply Not to the whole expression" do - node = Nodes::And.new @attr.eq(10), @attr.eq(11) + node = Nodes::And.new [@attr.eq(10), @attr.eq(11)] sql = @visitor.accept Nodes::Not.new(node) sql.must_be_like %{NOT ("users"."id" = 10 AND "users"."id" = 11)} end @@ -82,7 +89,7 @@ module Arel end it "should visit_Arel_Nodes_And" do - node = Nodes::And.new @attr.eq(10), @attr.eq(11) + node = Nodes::And.new [@attr.eq(10), @attr.eq(11)] @visitor.accept(node).must_be_like %{ "users"."id" = 10 AND "users"."id" = 11 } @@ -96,7 +103,7 @@ module Arel end it "should visit visit_Arel_Attributes_Time" do - attr = Attributes::Time.new(@attr.relation, @attr.name, @attr.column) + attr = Attributes::Time.new(@attr.relation, @attr.name) @visitor.accept attr end @@ -164,7 +171,9 @@ module Arel end in_node = Nodes::In.new @attr, %w{ a b c } visitor = visitor.new(Table.engine) - visitor.expected = @attr.column + visitor.expected = Table.engine.connection.columns(:users).find { |x| + x.name == 'name' + } visitor.accept(in_node).must_equal %("users"."name" IN ('a', 'b', 'c')) end end @@ -219,7 +228,9 @@ module Arel end in_node = Nodes::NotIn.new @attr, %w{ a b c } visitor = visitor.new(Table.engine) - visitor.expected = @attr.column + visitor.expected = Table.engine.connection.columns(:users).find { |x| + x.name == 'name' + } visitor.accept(in_node).must_equal %("users"."name" NOT IN ('a', 'b', 'c')) end end |