aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-03-16 19:10:37 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-03-16 19:10:37 -0300
commit8f3bd3db494f2218650d1487acede208d3f550cb (patch)
tree08f45ff86b2c89494e79c13bf62fb6f63fe9123c /activerecord/lib/active_record/connection_adapters
parenteaf38575bb29680071233f03e53813ba1404e145 (diff)
parent4794a9a6c18439657a2f888d394a85ae93368190 (diff)
downloadrails-8f3bd3db494f2218650d1487acede208d3f550cb.tar.gz
rails-8f3bd3db494f2218650d1487acede208d3f550cb.tar.bz2
rails-8f3bd3db494f2218650d1487acede208d3f550cb.zip
Merge pull request #19359 from yahonda/mysql_subclient
Materialize subqueries by adding `DISTINCT` to suport MySQL 5.7.6 and later
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
index 9625fcf9b8..7e41772227 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -785,7 +785,9 @@ module ActiveRecord
subselect = Arel::SelectManager.new(select.engine)
subselect.project Arel.sql(key.name)
- subselect.from subsubselect.as('__active_record_temp')
+ # Materialized subquery by adding distinct
+ # to work with MySQL 5.7.6 which sets optimizer_switch='derived_merge=on'
+ subselect.from subsubselect.distinct.as('__active_record_temp')
end
def add_index_length(option_strings, column_names, options = {})