diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-01-29 18:48:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 18:48:35 -0500 |
commit | 4734812ec595aa1a3951acc646d3b304fe7f0098 (patch) | |
tree | 98dac5466a8792780e34af6bc65048975381699f /activerecord/lib/active_record/connection_adapters | |
parent | ca1d13a1587330b370d737be9acdefababe027b0 (diff) | |
parent | b7b3e20333056fcec4725b3f87659acbcd214ee4 (diff) | |
download | rails-4734812ec595aa1a3951acc646d3b304fe7f0098.tar.gz rails-4734812ec595aa1a3951acc646d3b304fe7f0098.tar.bz2 rails-4734812ec595aa1a3951acc646d3b304fe7f0098.zip |
Merge pull request #31814 from fatkodima/index-nulls-order
Dump correctly index nulls order for PostgreSQL
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 8 |
1 files changed, 6 insertions, 2 deletions
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(/(?<column>\w+)\s?(?<opclass>\w+_ops)?\s?(?<desc>DESC)?\s?(?<nulls>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 |