aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-09-08 18:14:02 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-09-08 18:14:02 +0000
commit84bfdafa085daa11aa63491a7856638e05730727 (patch)
treeb2c0447dbb27f8cb06736b78d82152bd4fdf49c0 /activerecord/lib/active_record
parentf1b639cffb0aa1d88a5cf60ab2158bfc7a7f5904 (diff)
downloadrails-84bfdafa085daa11aa63491a7856638e05730727.tar.gz
rails-84bfdafa085daa11aa63491a7856638e05730727.tar.bz2
rails-84bfdafa085daa11aa63491a7856638e05730727.zip
Added parentheses around FROM clauses generated by Base and associations since MySQL 5 claim that to be the standard (and will screw up joins if its not there), see http://bugs.mysql.com/bug.php?id=13551 [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5073 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb2
-rwxr-xr-xactiverecord/lib/active_record/base.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index e2dca89d49..6168c8a723 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1131,7 +1131,7 @@ module ActiveRecord
def construct_finder_sql_with_included_associations(options, join_dependency)
scope = scope(:find)
- sql = "SELECT #{column_aliases(join_dependency)} FROM #{(scope && scope[:from]) || options[:from] || table_name} "
+ sql = "SELECT #{column_aliases(join_dependency)} FROM (#{(scope && scope[:from]) || options[:from] || table_name}) "
sql << join_dependency.join_associations.collect{|join| join.association_join }.join
add_joins!(sql, options, scope)
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index e9c9212560..756d63dfdb 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1089,7 +1089,7 @@ module ActiveRecord #:nodoc:
def construct_finder_sql(options)
scope = scope(:find)
sql = "SELECT #{(scope && scope[:select]) || options[:select] || '*'} "
- sql << "FROM #{(scope && scope[:from]) || options[:from] || table_name} "
+ sql << "FROM (#{(scope && scope[:from]) || options[:from] || table_name}) "
add_joins!(sql, options, scope)
add_conditions!(sql, options[:conditions], scope)