-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Remove column restrictions for #count
, let the database raise if the SQL is invalid.
#10710
Remove column restrictions for #count
, let the database raise if the SQL is invalid.
#10710
Conversation
@jonleighton this is the patch I asked you about. What do you think? |
@neerajdotname maybe you could give me your thoughts on this one? |
@senny PR looks good to me. +1. |
@senny sorry for my slowness. I am happy to merge this, but it needs a rebase. Also could you expand the changelog message to note that the previous behaviour was untested and surprising, which is why we're making this change. Also would be good to note in changelog that people can do |
@jonleighton I rebased the PR and extended the CHANGELOG to include the pieces that you mentioned. Can you take another look? |
…ounts Remove column restrictions for `#count`, let the database raise if the SQL is invalid.
…ounts Remove column restrictions for `#count`, let the database raise if the SQL is invalid. Conflicts: activerecord/CHANGELOG.md
…ounts Remove column restrictions for `#count`, let the database raise if the SQL is invalid. Conflicts: activerecord/CHANGELOG.md
…ise_on_counts". This commit causes certain associations to no longer be able to be found through includes (polymorphic belongs_to). This reverts commit 433e75f.
Due to Rails pull request #10710, count without a parameter and empty? don't work with a pg_search relation. rails/rails#10710
Could you tell me where exactly to change the path to the file, the version of rails 5.0.3 |
Fixes #5554
Previously the code path for
#count
used some validation logic and used to fall back on#count(:all)
. This prevented the execution of some specific count queries.This patch gets rid of the validation logic and let's the database decide if the query is valid or not. One backwards incompatible result of this patch is the following:
This count will now blow up because it you can't count on two columns. The solution is to specify the counting column explicitly: