Sha256: bc64069f0a3985acb4cf6852ab4b78f972e28af36486190253fa62b26db9ac8c

Contents?: true

Size: 852 Bytes

Versions: 22

Compression:

Stored size: 852 Bytes

Contents

module ActiveRecord
  module ConnectionAdapters
    class SQLite3Adapter
      def join_to_update(update, select, key)
        if key.is_a?(::CompositePrimaryKeys::CompositeKeys)
          subselect = subquery_for(key, select)
          subselect_aliased = Arel::Nodes::TableAlias.new(subselect, 'cpk_inner')
          cpk_subselect = Arel::SelectManager.new(subselect_aliased)
          cpk_subselect.project('*')
          key.each do |a_key|
            where_expr = subselect_aliased[a_key.name].eq(update.ast.relation[a_key.name])
            cpk_subselect.where(where_expr)
          end
          where_clause = Arel::Nodes::SqlLiteral.new("EXISTS (#{cpk_subselect.to_sql})")
          update.where(where_clause)
        else
          super
        end
      end
      alias join_to_delete join_to_update
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
composite_primary_keys-11.3.1 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.2.0 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.1.0 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.0.3 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.0.2 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-10.0.5 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-9.0.10 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.0.1 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.0.0 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-10.0.4 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-9.0.9 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-10.0.3 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.0.0.rc1 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.0.0.beta4 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.0.0.beta3 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.0.0.beta2 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-11.0.0.beta1 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-10.0.2 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-10.0.1 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
composite_primary_keys-9.0.8 lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb