method
columns
rails latest stable - Class:
ActiveRecord::ConnectionAdapters::SQLite3Adapter
Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v5.0.0.1) is shown here.
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 302
def columns(table_name) # :nodoc:
table_name = table_name.to_s
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
collation = field['collation']
sql_type = field['type']
type_metadata = fetch_type_metadata(sql_type)
new_column(field['name'], field['dflt_value'], type_metadata, field['notnull'].to_i == 0, table_name, nil, collation)
end
end Related methods
- Instance methods
- active?
- add_column
- allowed_index_name_length
- arel_visitor
- begin_db_transaction
- change_column
- change_column_default
- change_column_null
- clear_cache!
- columns
- commit_db_transaction
- data_source_exists?
- data_sources
- disconnect!
- encoding
- exec_delete
- exec_query
- exec_rollback_db_transaction
- exec_update
- execute
- explain
- indexes
- last_inserted_id
- native_database_types
- primary_keys
- remove_column
- remove_index
- rename_column
- rename_table
- requires_reloading?
- schema_creation
- supports_datetime_with_precision?
- supports_ddl_transactions?
- supports_explain?
- supports_index_sort_order?
- supports_migrations?
- supports_multi_insert?
- supports_partial_index?
- supports_primary_key?
- supports_savepoints?
- supports_statement_cache?
- supports_views?
- table_exists?
- tables
- valid_alter_table_type?
- valid_type?
- view_exists?
- views
- Class methods
- new
- Protected methods
-
alter_table -
copy_table -
copy_table_contents -
copy_table_indexes -
move_table -
sqlite_version -
table_structure -
translate_exception - Private methods
-
table_structure_with_collation