Fix a raw SQL for MySQL2 - #3529
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the raw SQL check in the DropLegacyModels migration so it works correctly with MySQL2 by using select_value instead of execute(...).first.
- Replace
execute(...).first["total_count"]withselect_value(...) - Remove the unused SQL alias
total_countin the query
ozovalihasan
marked this pull request as ready for review
July 14, 2025 13:58
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.
Description
is returning
[0]for MySQL2 and{"total_count" => 0}for SQLite3 and PostgreSQL. So, it is causing an error.It is fixed to return
0;What is the problem?
SQLite2 returns result of high-level queries in a hash. So, it doesn't cause any issue when working with ActiveRecord. But, the result of lower-level
#executemethod is returned in an array.Related Issue
#3458
Type of Change
Checklist
rake test)-- Tested manually
-- No need to document