method
columns
v4.2.9 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::SQLite3Adapter
columns(table_name)public
Returns an array of Column objects for the table specified by table_name.
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 374
def columns(table_name) #:nodoc:
table_structure(table_name).map do |field|
case field["dflt_value"]
when /^null$/
field["dflt_value"] = nil
when /^'(.*)'$/
field["dflt_value"] = $1.gsub("''", "'")
when /^"(.*)"$/
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 Related methods
- Instance methods
- _quote
- _type_cast
- active?
- add_column
- allowed_index_name_length
- begin_db_transaction
- change_column
- change_column_default
- change_column_null
- clear_cache!
- columns
- commit_db_transaction
- create
- data_source_exists?
- data_sources
- delete_sql
- disconnect!
- encoding
- exec_delete
- exec_query
- exec_rollback_db_transaction
- exec_update
- execute
- explain
- indexes
- insert_sql
- last_inserted_id
- native_database_types
- primary_key
- quote_column_name
- quote_string
- quote_table_name_for_assignment
- quoted_date
- remove_column
- remove_index!
- rename_column
- rename_table
- requires_reloading?
- select_rows
- supports_ddl_transactions?
- supports_explain?
- supports_index_sort_order?
- supports_migrations?
- supports_partial_index?
- supports_primary_key?
- supports_savepoints?
- supports_statement_cache?
- supports_views?
- table_exists?
- tables
- update_sql
- valid_alter_table_type?
- Class methods
- new
- Protected methods
-
alter_table -
copy_table -
copy_table_contents -
copy_table_indexes -
initialize_type_map -
move_table -
sqlite_version -
table_structure -
translate_exception