[migration] Stripping leading and trailing whitespace #8261
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.
CATEGORY
Choose one
SUMMARY
Similar to #7084 this PR strips leading and trailing whitespace (produced when using the forms) from specific non-NULL string columns. Previously #7084 dealt only with the cases where the values contained only whitespace.
We ran into this issue when trying to debug a security issue were the table names weren't matching due to trailing whitespace. It seems prudent that the records in Superset's schema be trustworthy and it's more desirable to clean this up via a migration than having to call
.strip()
every time we dealing with records from the database.Note depending on the state of the database stripping whitespace may lead to duplicate names which could violate uniqueness constraints and cause the migration to fail. Manually intervention may be required. For example the following MySQL query illustrates SQL metrics which are duplicates after spaces (including tabs) are removed:
TEST PLAN
Ran
superset db upgrade
(andsuperset db downgrade
) and verified that the leading and trailing whitespaces were removed.ADDITIONAL INFORMATION
REVIEWERS
to: @etr2460 @graceguo-supercat @michellethomas @mistercrunch