Repository navigation
Mutate readonly LOB attributes in place in the CLOB/NCLOB specs - #2973
Merged
Merged
Conversation
rails/rails@0f6c0a05e2 makes assignment to an `attr_readonly` attribute on a persisted record raise ActiveRecord::ReadonlyAttributeError by default (and deprecates `raise_on_assign_to_attr_readonly`), so the specs that assigned a new value to a readonly CLOB/NCLOB column failed before reaching save. Change the value in place instead, check that the change is detected, and keep asserting that save does not write it. Also assert that assigning a new value raises, which documents why the specs mutate in place and catches a future change in Rails behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yahonda
force-pushed
the
fix-clob-attr-readonly-specs
branch
from
October 23, 2026 08:59
73d9ffa to
3a0fd2f
Compare
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.
Summary
Six examples in
text_spec.rbandnational_character_text_spec.rbfail on current Rails main withActiveRecord::ReadonlyAttributeError:should respect attr_readonly setting for CLOB/NCLOB column(also theprepared_statementsdisabled variant)should work for serialized readonly CLOB/NCLOB columnsrails/rails@0f6c0a05e2 ("Inline
_write_attributein generated writer methods", 2026-10-19) makes assigning to anattr_readonlyattribute on a persisted record raise by default, and deprecatesconfig.active_record.raise_on_assign_to_attr_readonly. These specs assigned a new value to the readonly column, so they failed before reachingsave.The specs check that the adapter's LOB writing does not write a readonly column (
record_changed_lobsinlob.rbskips readonly attributes). They now change the value in place (String#replace, or a key added to the serialized Hash) instead of assigning it. Each spec first checks that assignment raisesActiveRecord::ReadonlyAttributeError, which documents why the value is changed in place and will catch a future change in Rails. It then checkswill_save_change_to_comments?is true and keeps asserting that the reloaded value is unchanged. The serialized specs start from{}instead ofnil, because anilvalue cannot be changed in place.No library code changes.
Testing
CRuby 4.0.7, Oracle Database 23.26, Rails main fa15ed655a. Both spec files: 45 examples, 0 failures, with and without
ORACLE_ENHANCED_PREPARED_STATEMENTS_FALSE=1. Before this change, 6 of them failed on master 659e906.As a check, I removed the readonly filter from
record_changed_lobsand ran the specs again. The twoprepared_statementsdisabled examples then fail. With prepared statements on, the readonly examples pass either way.🤖 Generated with Claude Code