diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-10 13:30:49 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-10 13:30:49 -0700 |
commit | f33ee69d59d2b06da3c3c1b24fc9bb640bf6ed25 (patch) | |
tree | c3a19a432730f04a8c7f9bfbd1aae1bdaafd7a6f /activerecord/lib/active_record/connection_adapters | |
parent | 0bac4c7e0287faa81461c94e6f3a38041b4181ee (diff) | |
download | rails-f33ee69d59d2b06da3c3c1b24fc9bb640bf6ed25.tar.gz rails-f33ee69d59d2b06da3c3c1b24fc9bb640bf6ed25.tar.bz2 rails-f33ee69d59d2b06da3c3c1b24fc9bb640bf6ed25.zip |
reducing funcalls, cleaning up primary key methods for sqlite adapter
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 117cf447df..b7f730d06a 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -190,16 +190,21 @@ module ActiveRecord def indexes(table_name, name = nil) #:nodoc: execute("PRAGMA index_list(#{quote_table_name(table_name)})", name).map do |row| - index = IndexDefinition.new(table_name, row['name']) - index.unique = row['unique'].to_i != 0 - index.columns = execute("PRAGMA index_info('#{index.name}')").map { |col| col['name'] } - index + IndexDefinition.new( + table_name, + row['name'], + row['unique'].to_i != 0, + execute("PRAGMA index_info('#{row['name']}')").map { |col| + col['name'] + }) end end def primary_key(table_name) #:nodoc: - column = table_structure(table_name).find {|field| field['pk'].to_i == 1} - column ? column['name'] : nil + column = table_structure(table_name).find { |field| + field['pk'].to_i == 1 + } + column && column['name'] end def remove_index!(table_name, index_name) #:nodoc: |