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-43998: Properly validate default values and fix their handling in SQL metadata #61
Conversation
ef57f1b
to
1151625
Compare
5dc6957
to
5005bef
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.
I am concerned with using JSON formatting for default string value. Do we have a test for MetadataBuilder
which uses non-empty default for a string column (and generates actual schema)?
5005bef
to
a7cdc35
Compare
b8c5e8b
to
5b6c6b9
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.
Looks good, one minor comment.
5b6c6b9
to
03ebd9d
Compare
This adds validation of the column `value` field, which provides a default that is passed to `server_default` when creating a SQLAlchemy column. The `MetaDataBuilder` was updated to properly handle these values depending on their type and content. Strings are quoted, except when they represent SQL functions such as `CURRENT_TIMESTAMP`. Tests were added to check that the validation functions properly for all of the Felis datatypes.
03ebd9d
to
8bcdae2
Compare
This fixes the handling of the
value
field when creating SQLAlchemy metadata. String literals are quoted, except when the value is a SQL function such asCURRENT_TIMESTAMP
. In this case, quotes are omitted.A thorough validation function was also added to the data model for checking
value
if it was provided. This will make sure that the provided value is valid given the datatype of the column.Finally, a new test method was added to check the validation function for all of the Felis datatypes, both when valid and invalid data is provided.