From e199dc1a570d4f0d9a07628268835bce5aab2732 Mon Sep 17 00:00:00 2001 From: Dan McClain Date: Mon, 25 Mar 2013 13:33:37 -0400 Subject: Adds support for concurrent indexing in PostgreSQL adapter Adds support for algorithm option in MySQL indexes Moves USING and algorithm options upstream The syntax is still specific to the Adapter, so the actual executed string happens in the corresponding adapter --- .../connection_adapters/abstract/schema_statements.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 26cacbde37..35f1112798 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -752,11 +752,13 @@ module ActiveRecord index_name = index_name(table_name, column: column_names) if Hash === options # legacy support, since this param was a string - options.assert_valid_keys(:unique, :order, :name, :where, :length, :internal, :using) + options.assert_valid_keys(:unique, :order, :name, :where, :length, :internal, :using, :algorithm) index_type = options[:unique] ? "UNIQUE" : "" index_name = options[:name].to_s if options.key?(:name) max_index_length = options.fetch(:internal, false) ? index_name_length : allowed_index_name_length + algorithm = index_algorithms[options[:algorithm]] + using = "USING #{options[:using]}" if options[:using].present? if supports_partial_index? index_options = options[:where] ? " WHERE #{options[:where]}" : "" @@ -772,6 +774,7 @@ module ActiveRecord index_type = options max_index_length = allowed_index_name_length + algorithm = using = nil end if index_name.length > max_index_length @@ -782,7 +785,7 @@ module ActiveRecord end index_columns = quoted_columns_for_index(column_names, options).join(", ") - [index_name, index_type, index_columns, index_options] + [index_name, index_type, index_columns, index_options, algorithm, using] end def index_name_for_remove(table_name, options = {}) -- cgit v1.2.3 From 203e0e0e4a863a25fedfe6985b371c3f4cfc6839 Mon Sep 17 00:00:00 2001 From: Dan McClain Date: Mon, 25 Mar 2013 22:41:29 -0400 Subject: Checks :algorithm argument for valid values --- .../connection_adapters/abstract/schema_statements.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 35f1112798..d5ae4058ed 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -757,7 +757,13 @@ module ActiveRecord index_type = options[:unique] ? "UNIQUE" : "" index_name = options[:name].to_s if options.key?(:name) max_index_length = options.fetch(:internal, false) ? index_name_length : allowed_index_name_length - algorithm = index_algorithms[options[:algorithm]] + + if index_algorithms.key?(options[:algorithm]) + algorithm = index_algorithms[options[:algorithm]] + elsif options[:algorithm].present? + raise ArgumentError.new("Algorithm must be one of the following: #{index_algorithms.keys.map(&:inspect).join(', ')}") + end + using = "USING #{options[:using]}" if options[:using].present? if supports_partial_index? -- cgit v1.2.3