From 11f929b5c485adab60ea2d8b515ef2abcf5400f4 Mon Sep 17 00:00:00 2001 From: Daniel Cadenas Date: Tue, 31 May 2011 00:40:11 -0300 Subject: Add nodes for boolean constants This is useful for dynamically created predicates e.g: expr1 = table.create_false expr2 = table.create_false expr1 = create_a_predicate() if some_condition expr2 = create_another_predicate() if some_other_condition table.where(expr1.and(expr2)) --- test/visitors/test_to_sql.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/visitors') diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb index b52722ddd6..3b58c71cd8 100644 --- a/test/visitors/test_to_sql.rb +++ b/test/visitors/test_to_sql.rb @@ -325,6 +325,22 @@ module Arel end end + describe 'Constants' do + it "should handle true" do + test = Table.new(:users).create_true + @visitor.accept(test).must_be_like %{ + TRUE + } + end + + it "should handle false" do + test = Table.new(:users).create_false + @visitor.accept(test).must_be_like %{ + FALSE + } + end + end + describe 'TableAlias' do it "should use the underlying table for checking columns" do test = Table.new(:users).alias('zomgusers')[:id].eq '3' -- cgit v1.2.3