-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Qualify column names in calculation #21756
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @matthewd (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
The last CI failure looks like because master is failing... |
@@ -102,6 +102,12 @@ def test_should_group_by_summed_field | |||
assert_equal 60, c[2] | |||
end | |||
|
|||
def test_should_qualify_fields_by_group | |||
assert_nothing_raised do | |||
AuditLog.joins(:developer).group(:id).count |
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 we check the value to make sure that this is doing the right thing? Not raising an exception doesn't mean that there isn't necessarily some issue
I've restarted the build for you. Master is passing now. Other than that one comment this looks fine. Please squash your commits and add a changelog entry. |
Ok now master is passing. It's been a long afternoon. >_> |
Column names inserted via `group` have to be qualified with table name.
888b5a1
to
8f41355
Compare
end | ||
end | ||
|
||
def test_should_calculate_against_given_relation |
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.
I am not very sure which test I should add. Is this ok?
Added test and updated CHANGELOG, and rebased because CHANGELOG update causes a conflict. |
Squashed and merged manually in 03aacc5 |
Qualify column names in calculation
This is to qualify column names inserted by
group
in calculation query.A calculation including
joins
andgroup
like the following may cause a SQL error.Here, column name given to
group
call also exists in the joined table. The column name given viagroup
will not qualified with table names, and the result is an error.This patch is to fix this by qualifying the column names with table name.