CHANGELOG & improvements to #16649

* Require either FIRST or LAST qualifier for "NULLS ..."
* Require whitespace before "NULLS ..."
This commit is contained in:
Godfrey Chan 2014-08-23 23:54:22 -07:00
parent 5b27d15ff8
commit 4287f6d456
2 changed files with 9 additions and 2 deletions

@ -1,3 +1,10 @@
* Fixed a regression where whitespaces were stripped from DISTINCT queries in
PostgreSQL.
*Agis Anastasopoulos*
Fixes #16623.
* Fix has_many :through relation merging failing when dynamic conditions are
passed as a lambda with an arity of one.

@ -549,8 +549,8 @@ def columns_for_distinct(columns, orders) #:nodoc:
# Convert Arel node to string
s = s.to_sql unless s.is_a?(String)
# Remove any ASC/DESC modifiers
s.gsub(/\s+(?:ASC|DESC)\s*/i, '')
.gsub(/\s*NULLS\s+(?:FIRST|LAST)?\s*/i, '')
s.gsub(/\s+(?:ASC|DESC)\b/i, '')
.gsub(/\s+NULLS\s+(?:FIRST|LAST)\b/i, '')
}.reject(&:blank?).map.with_index { |column, i| "#{column} AS alias_#{i}" }
[super, *order_columns].join(', ')