-
Notifications
You must be signed in to change notification settings - Fork 22k
Fix postgresql adapter #columns_for_distinct trimming whitespace it shouldn't #16649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The travis failures are irrelevant with the PR. |
@@ -549,7 +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*(?:NULLS\s+(?:FIRST|LAST)\s*)?/i, '') | |||
s.gsub(/\s+(ASC|DESC)\s*/i, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can keep the (?:
on (?:ASC|DESC)
- we don't use the capture
Fixed #columns_for_distinct of postgresql adapter Conflicts: activerecord/CHANGELOG.md Conflicts: activerecord/CHANGELOG.md
Looking good. Ready for merge and backport. |
@@ -549,7 +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*(?:NULLS\s+(?:FIRST|LAST)\s*)?/i, '') | |||
s.gsub(/\s+(?:ASC|DESC)\s*/i, '') | |||
.gsub(/\s*NULLS\s+(?:FIRST|LAST)?\s*/i, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make (?:FIRST|LAST)
optional?
Also, I don't like the fact that we don't require whitespace before NULLS
. Can we just remove the trailing \s*
from both expressions instead?
And let's end both with a \b
, for similar reasons: we're looking for whole words here.
Fix postgresql adapter #columns_for_distinct trimming whitespace it shouldn't
* Require either FIRST or LAST qualifier for "NULLS ..." * Require whitespace before "NULLS ..."
Fix postgresql adapter #columns_for_distinct trimming whitespace it shouldn't
* Require either FIRST or LAST qualifier for "NULLS ..." * Require whitespace before "NULLS ..."
Fix postgresql adapter #columns_for_distinct trimming whitespace it shouldn't
* Require either FIRST or LAST qualifier for "NULLS ..." * Require whitespace before "NULLS ..." Conflicts: activerecord/CHANGELOG.md
Fix postgresql adapter #columns_for_distinct trimming whitespace it shouldn't Conflicts: activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
* Require either FIRST or LAST qualifier for "NULLS ..." * Require whitespace before "NULLS ..." Conflicts: activerecord/CHANGELOG.md
Fix postgresql adapter #columns_for_distinct trimming whitespace it shouldn't Conflicts: activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
* Require either FIRST or LAST qualifier for "NULLS ..." * Require whitespace before "NULLS ..." Conflicts: activerecord/CHANGELOG.md Conflicts: activerecord/CHANGELOG.md
Merged into master, 4-1-stable, 4-1-6, 4-0-stable, 4-0-10, along with a CHANGELOG entry and @matthewd's suggestions. Thank you all ❤️ 💚 💙 💛 💜 |
Fixes the regression described in #16623 present in 4.0.10rc1 & 4.1.6.rc1. It was introduced by 3d5a201.