Skip to content
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

Add ActiveRecord::Relation#readonly? #51371

Merged
merged 1 commit into from
May 27, 2024

Conversation

theodorton
Copy link
Contributor

@theodorton theodorton commented Mar 21, 2024

Indicates whether a relation was marked readonly.

Motivation / Background

There's currently no documented API to check if a relation is readonly. Workarounds include loading the records and checking those for readonly? or using accessing the undocumented readonly_value.

A Relation could be marked readonly and used as an indication to what should be rendered. This change makes that use case simpler.

Detail

Adds ActiveRecord::Relation#readonly? which behaves the same as ActiveRecord::Base#readonly? for the contained records.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Indicates whether a relation was marked readonly.
@theodorton theodorton force-pushed the relation-test-readonly branch from 00a1606 to d28e7c2 Compare May 27, 2024 19:51
@rafaelfranca rafaelfranca merged commit 58883a5 into rails:main May 27, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants