handling for string columns in Rails 8#679
Open
StephenVNelson wants to merge 1 commit intoshioyama:masterfrom
Open
handling for string columns in Rails 8#679StephenVNelson wants to merge 1 commit intoshioyama:masterfrom
StephenVNelson wants to merge 1 commit intoshioyama:masterfrom
Conversation
butschi
added a commit
to cleanwake/mobility
that referenced
this pull request
Jan 27, 2026
Add respond_to?(:right) checks before calling .right on select_values to handle both plain strings and Arel nodes. Fixes NoMethodError when calling .count on queries with non-Arel select values in Rails 8.0+. Ref: shioyama#678 Based on: shioyama#679
armellarcier
pushed a commit
to gammeo/mobility
that referenced
this pull request
Feb 4, 2026
Add respond_to?(:right) checks before calling .right on select_values to handle both plain strings and Arel nodes. Fixes NoMethodError when calling .count on queries with non-Arel select values in Rails 8.0+. Ref: shioyama#678 Based on: shioyama#679
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
Fixes a bug in
select_for_count(Rails 8.0+) where calling.rightonselect_values crashes when the array contains plain strings instead of
Arel nodes.
The Problem
When using Mobility with Rails 8.0+ and calling
.counton a query withselected columns, the code assumes all
select_valuesareArel::Nodes::Asobjects with a
.rightmethod. However, select_values can contain a mix ofplain strings (like
"id") and Arel nodes, causing:The Solution
Added
respond_to?(:right)checks before calling.righton select_valuesto safely handle both strings and Arel nodes.
Changes Made
respond_to?(:right)checks inselect_for_countmethodTest Results
All existing tests pass, plus 3 new tests:
# Rails 8.0 with Ruby 3.2.5 15 examples, 0 failuresRelated Issues
Closes #678
Related to
selectwith noorderclause #659 (comment)