instance method build_table_structure

Ruby on Rails edge

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

Signature

build_table_structure(basic_structure, column_strings)

No documentation comment.

Parameters

basic_structure req
column_strings req
Source
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 846
        def build_table_structure(basic_structure, column_strings)
          collation_hash = {}
          auto_increments = {}
          generated_columns = {}

          if column_strings.any?
            column_strings.each do |column_string|
              # This regex will match the column name and collation type and will save
              # the value in $1 and $2 respectively.
              collation_hash[$1] = $2 if COLLATE_REGEX =~ column_string
              auto_increments[$1] = true if PRIMARY_KEY_AUTOINCREMENT_REGEX =~ column_string
              generated_columns[$1] = $2 if GENERATED_ALWAYS_AS_REGEX =~ column_string
            end

            basic_structure.map do |column|
              column_name = column["name"]

              if collation_hash.has_key? column_name
                column["collation"] = collation_hash[column_name]
              end

              if auto_increments.has_key?(column_name)
                column["auto_increment"] = true
              end

              if generated_columns.has_key?(column_name)
                column["dflt_value"] = generated_columns[column_name]
              end

              column
            end
          else
            basic_structure.to_a
          end
        end

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

Defined in ActiveRecord::ConnectionAdapters::SQLite3Adapter

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