From b7b3e20333056fcec4725b3f87659acbcd214ee4 Mon Sep 17 00:00:00 2001 From: fatkodima Date: Thu, 25 Jan 2018 22:11:11 +0200 Subject: Dump correctly index nulls order for postgresql --- .../connection_adapters/postgresql/schema_statements.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index 8678fab2ac..7999434ad8 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -124,9 +124,13 @@ module ActiveRecord # add info on sort order (only desc order is explicitly specified, asc is the default) # and non-default opclasses - expressions.scan(/(\w+)(?: (?!DESC)(\w+))?(?: (DESC))?/).each do |column, opclass, desc| + expressions.scan(/(?\w+)\s?(?\w+_ops)?\s?(?DESC)?\s?(?NULLS (?:FIRST|LAST))?/).each do |column, opclass, desc, nulls| opclasses[column] = opclass.to_sym if opclass - orders[column] = :desc if desc + if nulls + orders[column] = [desc, nulls].compact.join(" ") + else + orders[column] = :desc if desc + end end end -- cgit v1.2.3