diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-08-23 23:54:22 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-08-23 23:54:22 -0700 |
commit | 4287f6d456518652bb1a2035c9ecf96f1be28f79 (patch) | |
tree | 7f56a882952423574d33d36a947bc046e6c31a3c | |
parent | 5b27d15ff87b4a057edae942f8173f5ceb4a9196 (diff) | |
download | rails-4287f6d456518652bb1a2035c9ecf96f1be28f79.tar.gz rails-4287f6d456518652bb1a2035c9ecf96f1be28f79.tar.bz2 rails-4287f6d456518652bb1a2035c9ecf96f1be28f79.zip |
CHANGELOG & improvements to #16649
* Require either FIRST or LAST qualifier for "NULLS ..."
* Require whitespace before "NULLS ..."
-rw-r--r-- | activerecord/CHANGELOG.md | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index c2e79e9f02..356911d340 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -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. 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 6d5270cfc6..323da7b717 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -549,8 +549,8 @@ module ActiveRecord # 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(', ') |