diff options
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 |