Support composite primary keys in write_lobs#2697
Merged
Merged
Conversation
Build the SELECT ... FOR UPDATE predicate from each PK component so CpkModel.create! with a CLOB or BLOB column works when the post-save LOB rewrite path runs (i.e. with prepared_statements: false). The single-PK shape stays byte-identical via Array(klass.primary_key). Closes rsim#2694.
2274349 to
d594e33
Compare
This was referenced May 5, 2026
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
Build the
SELECT ... FOR UPDATEpredicate inwrite_lobsfrom eachprimary-key component, so
CpkModel.create!with a CLOB or BLOBcolumn works when the post-save LOB rewrite path runs (the case the
TODO from #2693 flagged). The single-PK SQL stays byte-identical via
Array(klass.primary_key), so existing scalar-PK behavior is unchanged.Adds
cpk_docs(CPK + CLOB + BLOB) coverage tocomposite_primary_key_spec.rb, exercising both the defaultprepared_statements: truepath and theprepared_statements: falsepost-save rewrite path for both CLOB and BLOB.
Closes #2694.
Related
The
insert_fixtureLOB call site is broken on this Ruby /ActiveRecord-main combination by an unrelated
ORA-01002(theSELECT ... FOR UPDATEcursor fetch outside a transaction). Itreproduces with a single-column primary key as well, so the fix lives
in #2698 (closes #2696). Once that lands, a CPK + LOB
insert_fixturetest can be added on top of this PR's
cpk_docssetup.Test plan
bundle exec rubocopbundle exec rspec spec/active_record/connection_adapters/oracle_enhanced/composite_primary_key_spec.rb(42/42)ORACLE_ENHANCED_PREPARED_STATEMENTS_FALSE=1 bundle exec rspec spec/active_record/connection_adapters/oracle_enhanced/composite_primary_key_spec.rb(42/42)bundle exec rspec spec/active_record/oracle_enhanced/type/text_spec.rb(21/21, single-PK LOB regression)