Permalink
Browse files

Use quoted_table_name with arel.from() if no from values explicitly s…

…upplied. Arel seems to be spending a lot of time figuring out the FROM value otherwise.
  • Loading branch information...
1 parent 798d282 commit fa9f000246c2f6010f18bf40237d105b782873e2 @lifo lifo committed Jan 20, 2010
Showing with 4 additions and 2 deletions.
  1. +4 −2 activerecord/lib/active_record/relation/query_methods.rb
@@ -140,16 +140,18 @@ def build_arel
selects = @select_values.uniq
+ quoted_table_name = @klass.quoted_table_name
+
if selects.present?
selects.each do |s|
@implicit_readonly = false
arel = arel.project(s) if s.present?
end
else
- arel = arel.project(@klass.quoted_table_name + '.*')
+ arel = arel.project(quoted_table_name + '.*')
end
- arel = arel.from(@from_value) if @from_value.present?
+ arel = @from_value.present? ? arel.from(@from_value) : arel.from(quoted_table_name)
case @lock_value
when TrueClass

0 comments on commit fa9f000

Please sign in to comment.