Factor out the valid_column_definition_options method to AbstractAdapter class#47609
Merged
eileencodes merged 1 commit intorails:mainfrom Mar 9, 2023
Merged
Factor out the valid_column_definition_options method to AbstractAdapter class#47609eileencodes merged 1 commit intorails:mainfrom
valid_column_definition_options method to AbstractAdapter class#47609eileencodes merged 1 commit intorails:mainfrom
Conversation
Shopify is implementing a custom ActiveRecord adapter to integrate with [Vitess](https://vitess.io/), and we would like to overload the `valid_{column,table}_definition_options` methods and add additional valid options for schema migrations. For example: ```ruby module ActiveRecord module ConnectionAdapters class VitessMysql2Adapter < Mysql2Adapter ... def valid_table_definition_options super + [:skip_vschema_migrations, :sharding_keys, :auto_increment] end def valid_column_definition_options super + [:skip_vschema_migrations, :sharding_keys, :auto_increment] end end end end ``` This is the simplest possible change and factors out the various `valid_{table,column,primary_key}_definition_options` to be a public method on an adapter instance.
44b452f to
cdb8957
Compare
Member
|
I'm not sure these should be public, but if they are, they should almost certainly be |
davinlagerroos
pushed a commit
to umn-asr/oracle-enhanced
that referenced
this pull request
Feb 21, 2024
See rails/rails#46178 and rails/rails#47609 These were the options that were failing in the test suite.
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.
Motivation / Background
This Pull Request has been created because our team at Shopify is implementing a custom ActiveRecord adapter to integrate with Vitess, and we would like to overload the
valid_{column,table}_definition_optionsmethods and add additional valid options for schema migrations. For example:Detail
This Pull Request, as the simplest possible change, factors out the various
valid_{table,column,primary_key}_definition_optionsto be a public method on an adapter instance.This allows subclassing adapters to cleanly override their ancestor class' valid options.
Additional information
I don't see any harm in this, maybe except the awkwardness of the roundabout reference of
TableDefinition#valid_column_definition_options->SchemaStatements#valid_column_definition_options->ColumnDefinition::OPTION_NAMESChecklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]