aboutsummaryrefslogtreecommitdiffstats
path: root/test/visitors
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-03-04 06:13:22 +0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-03-04 06:17:18 +0800
commita85530820426f8baa4dbb1fa863313c6a6c69484 (patch)
tree728ee4b8f4ec71159ca0a931ba2a3408bca35b4e /test/visitors
parent2644bcec7dbe3a65277b3a6a141853484171535a (diff)
downloadrails-a85530820426f8baa4dbb1fa863313c6a6c69484.tar.gz
rails-a85530820426f8baa4dbb1fa863313c6a6c69484.tar.bz2
rails-a85530820426f8baa4dbb1fa863313c6a6c69484.zip
Add an #table_name method to Table and TableAlias, which always returns the actual table name, not the alias. Then fix ToSql#column_for to use this table name when checking whether the table exists (rather than before, where it was checking whether a table with the alias name exists, which was incorrect).
Diffstat (limited to 'test/visitors')
-rw-r--r--test/visitors/test_to_sql.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb
index c8ad40e242..2d5549ca43 100644
--- a/test/visitors/test_to_sql.rb
+++ b/test/visitors/test_to_sql.rb
@@ -259,6 +259,15 @@ module Arel
}
end
end
+
+ describe 'TableAlias' do
+ it "should use the underlying table for checking columns" do
+ test = Table.new(:users).alias('zomgusers')[:id].eq '3'
+ @visitor.accept(test).must_be_like %{
+ "zomgusers"."id" = 3
+ }
+ end
+ end
end
end
end