3.x fix for MySQL adapter to prevent MySQL 'LIMIT & IN/ALL/ANY/SOME subquery'" error #457
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.
In regards to bug report 450:
#450
This pull contains a fix for a MySQL error generated by a combination of
limit,
tag_counts, and
sum`ActiveRecord::StatementInvalid: Mysql2::Error: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery':
In other words, limit the model to the first 2 records, find tag counts for the 2 records, then sum those tag counts
MySQL generated 2.x
MySQL generated in 3.x
re: ActiveRecord::StatementInvalid: Mysql2::Error: This version of
MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery':
Solution:
Add a ActsAsTaggableOn::Tag.using_mysql?
method and then revert to the 2.x way ofdoing a group count in
.all_tags
and.all_tags_count
Also,
collection.rb
now has a private class method to switch between the 2.x and 3.x code. I've tentatively referred to it as.generate_tagging_scope_in_clause
until a better patch is put in place. I say "better" as in, this patch fixes the broken behavior and passes all the specs, but if there were performance reasons for the breaking behavior, this patch reverts that as it basically does the counting query for Mysql as it did back in acts-as-taggable 2.x