diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-14 11:43:57 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-14 11:43:57 -0800 |
commit | 09035e622f9876cddc558ea065929cb862ca0f13 (patch) | |
tree | a562054a732e91256ddc4c458ae931be6436d9d1 /activerecord/lib/active_record/connection_adapters | |
parent | c7cf7f476a47c9e4c60a369efa338a1fa9d81d6c (diff) | |
parent | b23330745bddd6729f95fb8487e3ec4857e4bb58 (diff) | |
download | rails-09035e622f9876cddc558ea065929cb862ca0f13.tar.gz rails-09035e622f9876cddc558ea065929cb862ca0f13.tar.bz2 rails-09035e622f9876cddc558ea065929cb862ca0f13.zip |
Merge branch 'master' into set_binds
* master:
don't establish a new connection when testing with `sqlite3_mem`.
sqlite >= 3.8.0 supports partial indexes
Don't try to get the subclass if the inheritance column doesn't exist
Enum mappings are now exposed via class methods instead of constants.
Fix fields_for documentation with index option [ci skip]
quick pass through Active Record CHANGELOG. [ci skip]
[ci skip] Grammar correction
single quotes for controller generated routes
[ci skip] Added alias to CSRF
Set NameError#name
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index b0a2bc7973..55533311f5 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -155,6 +155,10 @@ module ActiveRecord true end + def supports_partial_index? + sqlite_version >= '3.8.0' + end + # Returns true, since this connection adapter supports prepared statement # caching. def supports_statement_cache? @@ -397,13 +401,25 @@ module ActiveRecord # Returns an array of indexes for the given table. def indexes(table_name, name = nil) #:nodoc: exec_query("PRAGMA index_list(#{quote_table_name(table_name)})", 'SCHEMA').map do |row| + sql = <<-SQL + SELECT sql + FROM sqlite_master + WHERE name=#{quote(row['name'])} AND type='index' + UNION ALL + SELECT sql + FROM sqlite_temp_master + WHERE name=#{quote(row['name'])} AND type='index' + SQL + index_sql = exec_query(sql).first['sql'] + match = /\sWHERE\s+(.+)$/i.match(index_sql) + where = match[1] if match IndexDefinition.new( table_name, row['name'], row['unique'] != 0, exec_query("PRAGMA index_info('#{row['name']}')", "SCHEMA").map { |col| col['name'] - }) + }, nil, nil, where) end end |