Active Record Connection Adapters Schema
Cache
Methods
- A
- C
- D
- I
- N
- P
- S
- V
Class Public methods
new(connection) Link
new() Link
Instance Public methods
add(connection, table_name) Link
Add internal cache for table with table_name
.
# File activerecord/lib/active_record/connection_adapters/schema_cache.rb, line 325 def add(connection, table_name) if data_source_exists?(connection, table_name) primary_keys(connection, table_name) columns(connection, table_name) columns_hash(connection, table_name) indexes(connection, table_name) end end
cached?(table_name) Link
clear_data_source_cache!(_connection, name) Link
Clear out internal caches for the data source name
.
columns(connection, table_name) Link
Get the columns for a table
# File activerecord/lib/active_record/connection_adapters/schema_cache.rb, line 340 def columns(connection, table_name) if ignored_table?(table_name) raise ActiveRecord::StatementInvalid, "Table '#{table_name}' doesn't exist" end @columns.fetch(table_name) do @columns[deep_deduplicate(table_name)] = deep_deduplicate(connection.columns(table_name)) end end
columns_hash(connection, table_name) Link
Get the columns for a table as a hash, key is the column name value is the column object.
columns_hash?(connection, table_name) Link
Checks whether the columns hash is already cached for a table.
data_source_exists?(connection, name) Link
A cached lookup for table existence.
# File activerecord/lib/active_record/connection_adapters/schema_cache.rb, line 316 def data_source_exists?(connection, name) return if ignored_table?(name) prepare_data_sources(connection) if @data_sources.empty? return @data_sources[name] if @data_sources.key? name @data_sources[deep_deduplicate(name)] = connection.data_source_exists?(name) end
dump_to(filename) Link
indexes(connection, table_name) Link
# File activerecord/lib/active_record/connection_adapters/schema_cache.rb, line 363 def indexes(connection, table_name) @indexes.fetch(table_name) do if data_source_exists?(connection, table_name) @indexes[deep_deduplicate(table_name)] = deep_deduplicate(connection.indexes(table_name)) else [] end end end
init_with(coder) Link
# File activerecord/lib/active_record/connection_adapters/schema_cache.rb, line 289 def init_with(coder) @columns = coder["columns"] @columns_hash = coder["columns_hash"] @primary_keys = coder["primary_keys"] @data_sources = coder["data_sources"] @indexes = coder["indexes"] || {} @version = coder["version"] @database_version = coder["database_version"] unless coder["deduplicated"] derive_columns_hash_and_deduplicate_values end end
primary_keys(connection, table_name) Link
# File activerecord/lib/active_record/connection_adapters/schema_cache.rb, line 307 def primary_keys(connection, table_name) @primary_keys.fetch(table_name) do if data_source_exists?(connection, table_name) @primary_keys[deep_deduplicate(table_name)] = deep_deduplicate(connection.primary_key(table_name)) end end end