Check if internal metadata is enabled in create_table_and_set_flags
method
#49551
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.
Motivation / Background
I maintain a gem (pg-aws_rds_iam) that runs acceptance tests against supported versions of Active Record. When I added 7.1 to the test matrix, my test failed with the following error:
Detail
It seems that in 7.1 there is a new method,
ActiveRecord::InternalMetadata#create_table_and_set_flags
, which does not respect theuse_metadata_table: false
setting on the connection.https://github.com/rails/rails/blob/v7.1.0/activerecord/lib/active_record/internal_metadata.rb#L66-L70
create_table_and_set_flags
callscreate_table
(which is a no-op if the metadata table is disabled) and thenupdate_or_create_entry
(which assumes that the metadata table exists).This PR adds a guard clause to
create_table_and_set_flags
to match the other methods inInternalMetadata
.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
Tests are added or updated if you fix a bug or add a feature.- I'm not sure where or how to add a test for this fixCHANGELOG 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.