aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorfatkodima <fatkodima123@gmail.com>2018-01-25 22:11:11 +0200
committerfatkodima <fatkodima123@gmail.com>2018-01-28 18:37:52 +0200
commitb7b3e20333056fcec4725b3f87659acbcd214ee4 (patch)
treecdfb5b9d842e6b6ac6dcb9bfbfd02d4af868dbcb /activerecord/lib
parenta88eb9087260cca256c6faba40bf538d4a0289b3 (diff)
downloadrails-b7b3e20333056fcec4725b3f87659acbcd214ee4.tar.gz
rails-b7b3e20333056fcec4725b3f87659acbcd214ee4.tar.bz2
rails-b7b3e20333056fcec4725b3f87659acbcd214ee4.zip
Dump correctly index nulls order for postgresql
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb8
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