Browse files

Added parentheses around FROM clauses generated by Base and associati…

…ons 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
  • Loading branch information...
1 parent f1b639c commit 84bfdafa085daa11aa63491a7856638e05730727 @dhh dhh committed Sep 8, 2006
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* 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]
+
* Rename AR::Base#quote so people can use that name in their models. #3628 [Koz]
* Add deprecation warning for inferred foreign key. #6029 [Josh Susser]
View
2 activerecord/lib/active_record/associations.rb
@@ -1131,7 +1131,7 @@ def select_all_rows(options, join_dependency)
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)
View
2 activerecord/lib/active_record/base.rb
@@ -1089,7 +1089,7 @@ def type_name_with_module(type_name)
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)

0 comments on commit 84bfdaf

Please sign in to comment.