New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-41247: Add tool that checks for redundant datatype definitions #50
Conversation
Pydantic itself uses a global settings dictionary for data models, so follow this style for validation options.
This was needed in SQLAlchemy v1 but should not be needed in v2.
If there are 'mysql:datatype' annotations present in the column data, check that they are not redundant. The datatypes are checked to see if they compile to the same SQL string in the target dialect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few changes
Since the method to populate the ID map may be called multiple times if the schema is updated after being built, it is safer to construct the ID map in the post init hook rather than activate it using a validator.
d95b004
to
941933f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally this is what was agreed. Not enough time to review the code in detail, but it generally looks consistent with the package and our style rules.
DM-41247: Revert "Merge pull request #50 from lsst/tickets/DM-41247"
This adds a Pydantic validator that will identity variant type overrides, e.g.,
mysql:datatype
values, that appear to be redundant. To determine whether the datatypes are the same, they are each compiled to a SQL snippet. If the resultant SQL is identical, then the type override is considered to be superfluous and an error is raised.The validation needs to be turned on using the
-t/--check-redundant-datatypes
flag when running thevalidate
command.