Method: ActiveRecord::ConnectionAdapters::SQLite3Adapter#columns

Defined in:
lib/active_record/connection_adapters/sqlite3_adapter.rb

#columns(table_name) ⇒ Object

Returns an array of Column objects for the table specified by table_name.



388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/active_record/connection_adapters/sqlite3_adapter.rb', line 388

def columns(table_name) #:nodoc:
  table_structure(table_name).map do |field|
    case field["dflt_value"]
    when /^null$/i
      field["dflt_value"] = nil
    when /^'(.*)'$/m
      field["dflt_value"] = $1.gsub("''", "'")
    when /^"(.*)"$/m
      field["dflt_value"] = $1.gsub('""', '"')
    end

    sql_type = field['type']
    cast_type = lookup_cast_type(sql_type)
    new_column(field['name'], field['dflt_value'], cast_type, sql_type, field['notnull'].to_i == 0)
  end
end