diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-08-23 23:36:40 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-08-23 23:36:40 -0700 |
commit | 5b27d15ff87b4a057edae942f8173f5ceb4a9196 (patch) | |
tree | a31fdefdf8b02c81eb29cc82ccaf198084ed3d6d /activerecord/lib/active_record | |
parent | 33c05363e2ed52aa8bdbf5ebf9ee5226ab85ecbc (diff) | |
parent | 291fece47a954eb986816a89164bda599d54db46 (diff) | |
download | rails-5b27d15ff87b4a057edae942f8173f5ceb4a9196.tar.gz rails-5b27d15ff87b4a057edae942f8173f5ceb4a9196.tar.bz2 rails-5b27d15ff87b4a057edae942f8173f5ceb4a9196.zip |
Merge pull request #16649 from Agis-/pg-columns-for-distinct
Fix postgresql adapter #columns_for_distinct trimming whitespace it shouldn't
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 3 |
1 files changed, 2 insertions, 1 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 7042817672..6d5270cfc6 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -549,7 +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*(?:NULLS\s+(?:FIRST|LAST)\s*)?/i, '') + s.gsub(/\s+(?:ASC|DESC)\s*/i, '') + .gsub(/\s*NULLS\s+(?:FIRST|LAST)?\s*/i, '') }.reject(&:blank?).map.with_index { |column, i| "#{column} AS alias_#{i}" } [super, *order_columns].join(', ') |