Sha256: fb1455430b35e807d14741b1f91264e0e8877c0cc57ab8a414d5f9a16862d0c0

Contents?: true

Size: 707 Bytes

Versions: 4

Compression:

Stored size: 707 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module MySQL
      module DatabaseStatements
        def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
          sql, binds = to_sql_and_binds(arel, binds)
          value = exec_insert(sql, name, binds, pk, sequence_name)

          # CPK
          if pk.is_a?(Array)
            pk.map do |key|
              column = column_for(arel.ast.relation.name, key)
              column.auto_increment? ? last_inserted_id(value) : nil
            end
          else
            id_value || last_inserted_id(value)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
composite_primary_keys-12.0.8 lib/composite_primary_keys/connection_adapters/mysql/database_statements.rb
composite_primary_keys-12.0.6 lib/composite_primary_keys/connection_adapters/mysql/database_statements.rb
composite_primary_keys-12.0.5 lib/composite_primary_keys/connection_adapters/mysql/database_statements.rb
composite_primary_keys-12.0.4 lib/composite_primary_keys/connection_adapters/mysql/database_statements.rb