Remove has_primary_key?#2695
Merged
Merged
Conversation
`has_primary_key?` was an oracle-enhanced override of an abstract
adapter method that Rails itself removed in commit d1521719c5
("Removed support for accessing attributes on a
has_and_belongs_to_many join table", 2011-01-16) when the HABTM
attribute-access path that needed it was retired. oracle-enhanced
kept the override, but it has been dead surface for 14+ years:
- No in-tree caller. The only previous user, the original
`prefetch_primary_key?` cache-fill path, was refactored into
`prefetch_primary_key_from_dictionary` and now goes through
`primary_keys(table_name)` directly.
- Not part of the Rails abstract adapter API anymore. Rails callers
use `primary_key(table_name)` / `primary_keys(table_name)` instead.
- Marked `# :nodoc:` so no API contract.
- The single spec assertion added in rsim#2693
(`expect(@conn.has_primary_key?("uber_barcodes")).to be true`)
duplicated the immediately preceding `primary_keys` assertion;
removed alongside the method.
The body had also already lost its `(owner, desc_table_name)`
arguments (carried over from `pk_and_sequence_for`'s historical
signature, never functional because `pk_and_sequence_for` itself
unconditionally re-resolves them). Rather than keep a one-line
wrapper around `primary_keys(table_name).any?`, drop the method
entirely.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fc9deb1 to
47b3a6b
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
Remove
OracleEnhancedAdapter#has_primary_key?entirely. The method was an oracle-enhanced override of an abstract-adapter method that Rails itself removed in commit d1521719c5 ("Removed support for accessing attributes on a has_and_belongs_to_many join table", 2011-01-16) when the HABTM attribute-access path that needed it was retired. oracle-enhanced kept the override, but it has been dead surface for 14+ years.Why now / why outright removal
prefetch_primary_key?cache-fill path, was refactored intoprefetch_primary_key_from_dictionaryand now goes throughprimary_keys(table_name)directly.primary_key(table_name)/primary_keys(table_name)instead.# :nodoc:— no API contract is being broken.(owner, desc_table_name)arguments (carried over frompk_and_sequence_for's historical signature, never functional becausepk_and_sequence_foritself unconditionally re-resolves them viaresolve_data_source_name). The only thing left would have been a one-line wrapper aroundprimary_keys(table_name).any?— not worth keeping.expect(@conn.has_primary_key?("uber_barcodes")).to be true) duplicated the immediately precedingprimary_keysassertion; removed alongside the method.Diff
(Plus the deletion of one redundant spec line.)
Test plan
bundle exec rspec— full suite, 803 examples, 0 failures, 12 pre-existing pendingbundle exec rubocop— cleanhas_primary_key?inlib/orspec/