mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Make indexed columns easy to extract from the index name. Oracle users should explicitly assign index names due to field length restrictions.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4768 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -214,7 +214,7 @@ module ActiveRecord
|
|||||||
def index_name(table_name, options) #:nodoc:
|
def index_name(table_name, options) #:nodoc:
|
||||||
if Hash === options # legacy support
|
if Hash === options # legacy support
|
||||||
if options[:column]
|
if options[:column]
|
||||||
"#{table_name}_#{Array(options[:column]).join('_')}_index"
|
"index_#{table_name}_on_#{Array(options[:column]) * '_and_'}"
|
||||||
elsif options[:name]
|
elsif options[:name]
|
||||||
options[:name]
|
options[:name]
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -57,14 +57,17 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||||||
assert_nothing_raised { Person.connection.add_index("people", "last_name") }
|
assert_nothing_raised { Person.connection.add_index("people", "last_name") }
|
||||||
assert_nothing_raised { Person.connection.remove_index("people", "last_name") }
|
assert_nothing_raised { Person.connection.remove_index("people", "last_name") }
|
||||||
|
|
||||||
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
|
# Orcl nds shrt indx nms.
|
||||||
assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) }
|
unless current_adapter?(:OracleAdapter)
|
||||||
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
|
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
|
||||||
assert_nothing_raised { Person.connection.remove_index("people", :name => "people_last_name_first_name_index") }
|
assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) }
|
||||||
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
|
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
|
||||||
assert_nothing_raised { Person.connection.remove_index("people", "last_name_first_name") }
|
assert_nothing_raised { Person.connection.remove_index("people", :name => "index_people_on_last_name_and_first_name") }
|
||||||
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
|
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
|
||||||
assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) }
|
assert_nothing_raised { Person.connection.remove_index("people", "last_name_and_first_name") }
|
||||||
|
assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
|
||||||
|
assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) }
|
||||||
|
end
|
||||||
|
|
||||||
# quoting
|
# quoting
|
||||||
# Note: changed index name from "key" to "key_idx" since "key" is a Firebird reserved word
|
# Note: changed index name from "key" to "key_idx" since "key" is a Firebird reserved word
|
||||||
|
|||||||
Reference in New Issue
Block a user