diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-12 18:15:21 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-12 18:15:21 -0700 |
commit | d4abd35feb84db37815ecd8f0b37f657317105c1 (patch) | |
tree | dd1de06baa686e96868284df5534a5eb0bad0e2e /lib/arel | |
parent | 53159770271c24a4c0ba6bca6a9e09683157dd9d (diff) | |
download | rails-d4abd35feb84db37815ecd8f0b37f657317105c1.tar.gz rails-d4abd35feb84db37815ecd8f0b37f657317105c1.tar.bz2 rails-d4abd35feb84db37815ecd8f0b37f657317105c1.zip |
using table_alias when :as is passed to the constructor
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/table.rb | 5 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb index efdc34ed94..1519efa63b 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -14,6 +14,11 @@ module Arel @columns = nil @aliases = [] @table_alias = nil + + # Sometime AR sends an :as parameter to table, to let the table know that + # it is an Alias. We may want to override new, and return a TableAlias + # node? + @table_alias = engine[:as] if Hash === engine end def alias diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index be9a62325a..391d2ff1c4 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -139,7 +139,11 @@ module Arel end def visit_Arel_Table o - quote_table_name o.name + if o.table_alias + "#{quote_table_name o.name} #{quote_table_name o.table_alias}" + else + quote_table_name o.name + end end def visit_Arel_Nodes_In o |