Remove column restrictions for #count, let the database raise if the SQL is invalid.#10710
Merged
jonleighton merged 2 commits intorails:masterfrom Jun 9, 2013
Merged
Conversation
Member
Author
|
@jonleighton this is the patch I asked you about. What do you think? |
Member
Author
|
@neerajdotname maybe you could give me your thoughts on this one? |
|
@senny PR looks good to me. +1. |
Member
|
@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 |
Member
Author
|
@jonleighton I rebased the PR and extended the CHANGELOG to include the pieces that you mentioned. Can you take another look? |
jonleighton
added a commit
that referenced
this pull request
Jun 9, 2013
…ounts Remove column restrictions for `#count`, let the database raise if the SQL is invalid.
jonleighton
added a commit
that referenced
this pull request
Jun 9, 2013
…ounts Remove column restrictions for `#count`, let the database raise if the SQL is invalid. Conflicts: activerecord/CHANGELOG.md
jonleighton
added a commit
that referenced
this pull request
Jun 9, 2013
…ounts Remove column restrictions for `#count`, let the database raise if the SQL is invalid. Conflicts: activerecord/CHANGELOG.md
dhh
pushed a commit
that referenced
this pull request
Jun 11, 2013
…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.
nertzy
added a commit
to Casecommons/pg_search
that referenced
this pull request
Jan 5, 2014
Due to Rails pull request #10710, count without a parameter and empty? don't work with a pg_search relation. rails/rails#10710
This was referenced Jun 18, 2014
|
Could you tell me where exactly to change the path to the file, the version of rails 5.0.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5554
Previously the code path for
#countused 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: