instance method fetch_primary_keys

Ruby on Rails edge

Since edge Private — implementation detail, not part of the public API

Signature

fetch_primary_keys(tables)

No documentation comment.

Parameters

tables req
Source
# File activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb, line 822
        def fetch_primary_keys(tables)
          fetch_by_schema(tables) do |schema, group|
            by_name = query_all(<<~SQL).group_by { |row| row["table"] }
              SELECT table_name AS 'table', column_name AS 'column'
              FROM information_schema.statistics
              WHERE index_name = 'PRIMARY'
                AND table_schema = #{schema}
                AND table_name IN (#{quoted_table_names(group)})
              ORDER BY table_name, seq_in_index
            SQL

            group.index_with { |table| rows_for(by_name, table).map { |row| row["column"] } }
          end
        end

Defined in activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb line 822 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close