GitLab wurde erfolgreich aktualisiert. Dank regelmäßiger Updates bleibt das THM GitLab sicher und Sie profitieren von den neuesten Funktionen. Danke für Ihre Geduld.

Add support for explicit index order

ActiveRecord supports `:order` natively, but it is skipped because of
our specific patch to support opclasses.

Relevant AR code:
parent 420442c5
......@@ -130,9 +130,12 @@ def indexes(table_name, name = nil)
where = inddef.scan(/WHERE (.+)$/).flatten[0]
using = inddef.scan(/USING (.+?) /).flatten[0].to_sym
opclasses = Hash[inddef.scan(/\((.+?)\)(?:$| WHERE )/).flatten[0].split(',').map do |column_and_opclass|
column, opclass = column_and_opclass.split(' ').map(&:strip)
[column, opclass] if opclass
column, opclass = column_and_opclass.split(' ').map(&:strip)
end.reject do |column, opclass|
['desc', 'asc'].include?(opclass&.downcase) do |column, opclass|
[column, opclass] if opclass
index_attrs = [table_name, index_name, unique, column_names, [], orders, where, nil, using, nil, opclasses]
......@@ -151,6 +154,9 @@ def add_index(table_name, column_name, options = {}) #:nodoc:
def quoted_columns_for_index(column_names, options = {})
column_opclasses = options[:opclasses] || {} {|name| "#{quote_column_name(name)} #{column_opclasses[name]}"}
quoted_columns = Hash[ { |name| [name.to_sym, "#{quote_column_name(name)} #{column_opclasses[name]}"] }]
add_options_for_index_columns(quoted_columns, options).values
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment