-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
fix: DB exported with incorrect type #16037
Conversation
self, data: Dict[str, Any], **kwargs: Any | ||
) -> Dict[str, Any]: | ||
""" | ||
Fix ``schemas_allowed_for_csv_upload`` being a string. |
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.
would it make sense to run a migration/script to update the data in the table directly? I assume the size of these tables is relatively small.
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.
For sure! But I'm planning to work on a separate PR that fixes schemas_allowed_for_csv_upload
being stored incorrectly, I thought of doing the migration there.
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.
also, are we fixing the fe bug separately?
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.
Yep! :)
# Fix for DBs saved with an invalid ``schemas_allowed_for_csv_upload`` | ||
schemas_allowed_for_csv_upload = extra.get("schemas_allowed_for_csv_upload") | ||
if isinstance(schemas_allowed_for_csv_upload, str): | ||
extra["schemas_allowed_for_csv_upload"] = json.loads( | ||
schemas_allowed_for_csv_upload | ||
) |
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.
This won't be needed after we apply the migration fixing the DB, but for now we need it.
Codecov Report
@@ Coverage Diff @@
## master #16037 +/- ##
=======================================
Coverage 76.66% 76.67%
=======================================
Files 995 995
Lines 52784 52820 +36
Branches 6695 6695
=======================================
+ Hits 40467 40498 +31
- Misses 12092 12097 +5
Partials 225 225
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
LGTM!
* fix: DB exported with incorrect type * Fix export as well
* fix: DB exported with incorrect type * Fix export as well
* fix: DB exported with incorrect type * Fix export as well
* fix: DB exported with incorrect type * Fix export as well
SUMMARY
Some databases were saved with
schemas_allowed_for_csv_upload
as a JSON string, instead of a JSON object. When these databases are exported the ZIP payload has the incorrect schema, and can't be imported.This PR fixes the export, so that these databases are exported with the correct schema; and the import, so that any databases that were eventually exported can be imported.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
Before applying this PR, create a DB using the new custom form. Check that the DB is saved with incorrect
extra
:Note that the payload is incorrect becase
schemas_allowed_for_csv_upload
should be an array, not a string. One way to save a DB with the incorrect format like above is to add a schema, save the DB, remove the schema, and save the DB again.Export the DB, the YAML will look like this:
When importing the file it will fail the validation, because
schemas_allowed_for_csv_upload
is a string.With this PR, the import will work. Additionally, when exporting the incorrectly saved database the output YAML will look like this:
ADDITIONAL INFORMATION