diff options
author | Yasuo Honda <yasuo.honda@gmail.com> | 2015-03-16 12:52:02 +0000 |
---|---|---|
committer | Yasuo Honda <yasuo.honda@gmail.com> | 2015-03-16 17:05:47 +0000 |
commit | 4794a9a6c18439657a2f888d394a85ae93368190 (patch) | |
tree | de1067bf05f0970dc4a182f24ddbb6ddca01374d /activerecord/lib | |
parent | 017415ed19ae9307f138eee61e9f8cae33bb77ea (diff) | |
download | rails-4794a9a6c18439657a2f888d394a85ae93368190.tar.gz rails-4794a9a6c18439657a2f888d394a85ae93368190.tar.bz2 rails-4794a9a6c18439657a2f888d394a85ae93368190.zip |
Materialize subqueries by adding `DISTINCT`
to support MySQL 5.7.6 `optimizer_switch='derived_merge=on'`
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 4 |
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 = {}) |