diff options
Diffstat (limited to 'lib/active_relation/relations/table.rb')
-rw-r--r-- | lib/active_relation/relations/table.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/active_relation/relations/table.rb b/lib/active_relation/relations/table.rb index d642851687..a370b4266d 100644 --- a/lib/active_relation/relations/table.rb +++ b/lib/active_relation/relations/table.rb @@ -1,10 +1,10 @@ module ActiveRelation module Relations class Table < Base - attr_reader :table + attr_reader :name - def initialize(table) - @table = table + def initialize(name) + @name = name end def attributes @@ -19,10 +19,14 @@ module ActiveRelation def attribute(name) attributes_by_name[name.to_s] end + + def table_sql + "#{quote_table_name(name)}" + end private def attributes_by_name - @attributes_by_name ||= connection.columns(table, "#{table} Columns").inject({}) do |attributes_by_name, column| + @attributes_by_name ||= connection.columns(name, "#{name} Columns").inject({}) do |attributes_by_name, column| attributes_by_name.merge(column.name => Primitives::Attribute.new(self, column.name.to_sym)) end end |