diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-10 10:23:42 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-10 10:23:42 -0800 |
commit | 3092324ef4e2f6f096adfbcf92597502b3ce91aa (patch) | |
tree | e88523b0d13982371dfd6ec3d36000191d128e67 /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | |
parent | fc3fad8d85a82e2ac9ed5c108fb2410b72ab447b (diff) | |
parent | aaffc2acd5fa3104fa936c334ef9d50774071c8b (diff) | |
download | rails-3092324ef4e2f6f096adfbcf92597502b3ce91aa.tar.gz rails-3092324ef4e2f6f096adfbcf92597502b3ce91aa.tar.bz2 rails-3092324ef4e2f6f096adfbcf92597502b3ce91aa.zip |
Merge pull request #4956 from mhfs/pg_partial_indices
Add support for partial indices to PostgreSQL adapter
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 194c814e5b..f1940ea15f 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -302,6 +302,10 @@ module ActiveRecord true end + def supports_partial_index? + true + end + class StatementPool < ConnectionAdapters::StatementPool def initialize(connection, max) super @@ -885,8 +889,9 @@ module ActiveRecord # add info on sort order for columns (only desc order is explicitly specified, asc is the default) desc_order_columns = inddef.scan(/(\w+) DESC/).flatten orders = desc_order_columns.any? ? Hash[desc_order_columns.map {|order_column| [order_column, :desc]}] : {} + where = inddef.scan(/WHERE (.+)$/).flatten[0] - column_names.empty? ? nil : IndexDefinition.new(table_name, index_name, unique, column_names, [], orders) + column_names.empty? ? nil : IndexDefinition.new(table_name, index_name, unique, column_names, [], orders, where) end.compact end |