aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDan McClain <git@danmcclain.net>2013-03-25 22:41:29 -0400
committerDan McClain <git@danmcclain.net>2013-03-26 10:14:15 -0400
commit203e0e0e4a863a25fedfe6985b371c3f4cfc6839 (patch)
treea9ab67493cec101c24806cbfaf513948964943ae /activerecord/lib
parente199dc1a570d4f0d9a07628268835bce5aab2732 (diff)
downloadrails-203e0e0e4a863a25fedfe6985b371c3f4cfc6839.tar.gz
rails-203e0e0e4a863a25fedfe6985b371c3f4cfc6839.tar.bz2
rails-203e0e0e4a863a25fedfe6985b371c3f4cfc6839.zip
Checks :algorithm argument for valid values
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb8
1 files changed, 7 insertions, 1 deletions
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?