Sha256: 9760da94dd7ede25f0291719e7f2295e584997c22633befb9dda266dabb64d19

Contents?: true

Size: 719 Bytes

Versions: 20

Compression:

Stored size: 719 Bytes

Contents

module ActiveRecord
  module ConnectionAdapters
    class AbstractMysqlAdapter
      def subquery_for(key, select)
        subsubselect = select.clone
        subsubselect.projections = [key]

        # Materialize subquery by adding distinct
        # to work with MySQL 5.7.6 which sets optimizer_switch='derived_merge=on'
        subsubselect.distinct unless select.limit || select.offset || select.orders.any?

        subselect = Arel::SelectManager.new(select.engine)

        # CPK
        #subselect.project Arel.sql(key.name)
        subselect.project Arel.sql(Array(key).map(&:name).join(', '))

        subselect.from subsubselect.as('__active_record_temp')
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
composite_primary_keys-11.0.3 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-11.0.2 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-10.0.5 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-9.0.10 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-11.0.1 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-10.0.4 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-9.0.9 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-10.0.3 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-11.0.0.rc1 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-11.0.0.beta4 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-11.0.0.beta3 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-11.0.0.beta2 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-11.0.0.beta1 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-10.0.2 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-10.0.1 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-9.0.8 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-10.0.0 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-9.0.7 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-9.0.6 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb
composite_primary_keys-9.0.5 lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb