Permalink
Browse files

don't reinitialize the arel_table unless the table_name changes

  • Loading branch information...
dmathieu authored and tenderlove committed Jun 9, 2011
1 parent 7cca6a2 commit dc73c2c38feb018da37eda0a23c9411e15888eeb
Showing with 2 additions and 1 deletion.
  1. +2 −1 activerecord/lib/active_record/base.rb
@@ -659,6 +659,7 @@ def reset_sequence_name #:nodoc:
def set_table_name(value = nil, &block)
@quoted_table_name = nil
define_attr_method :table_name, value, &block
+ @arel_table = nil
@arel_table = Arel::Table.new(table_name, arel_engine)
@relation = Relation.new(self, arel_table)
@@ -892,7 +893,7 @@ def sti_name
end
def arel_table
- Arel::Table.new(table_name, arel_engine)
+ @arel_table ||= Arel::Table.new(table_name, arel_engine)
end
def arel_engine

0 comments on commit dc73c2c

Please sign in to comment.