instance method fetch_column_definitions

Ruby on Rails edge

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

Signature

fetch_column_definitions(tables)

No documentation comment.

Parameters

tables req
Source
# File activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb, line 1070
        def fetch_column_definitions(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 'Field', column_type AS 'Type',
                     column_default AS 'Default', is_nullable AS 'Null', extra AS 'Extra',
                     collation_name AS 'Collation', column_comment AS 'Comment'
              FROM information_schema.columns
              WHERE table_schema = #{schema}
                AND table_name IN (#{quoted_table_names(group)})
              ORDER BY table_name, ordinal_position
            SQL

            group.index_with do |table|
              fields = rows_for(by_name, table)

              next column_definitions(table) if fields.empty?

              fields.each { |field| unquote_mariadb_default(field) } if mariadb?

              fields
            end
          end
        end

Defined in activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb line 1070 · 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