Import/Export creates field with empty string rather than null
Version
Tested on pulp_rpm 3.28, core 3.70. Probably applies to lower versions.
Describe the bug
GIVEN a dataset exported from an rpm repository WHEN importing that with the option to create repositories equal True THEN the created repositories will contain optional fields [0] as empty strings rather than null (diverges from normal behavior)
[0] checksum_type and the deprecated [metadata_checksum_type, package_checksum_type, compression_type]
To Reproduce
Run test test_create_missing_repos, breakpoint after step 6 and check repositories in the database. There should be two repositories with empty string, rather than null.
On a database GUI (AnataresSQL here) the column shows more clearly what is null or not.
pulp=> select repository_ptr_id, checksum_type from rpm_rpmrepository where checksum_type is not null;
repository_ptr_id | checksum_type
--------------------------------------+---------------
0194f5f8-0cf3-7018-a331-de7feab46a2e |
0194f5f8-0d13-724c-be0e-41ff15eea629 |
(2 rows)
Alternatively, remove this workaround that casts empty string to null and watch this same test fail (because bindings validates that when creating a list/show response).
Expected behavior
These fields should have null values instead of empty string, as it happens when creating repos via the API.
Additional context
That was found during the core 3.70 compat changes, responding to strict validation from the bindings.
https://issues.redhat.com/browse/PULP-341
I believe this is down to default django-import-export behavior that changed in a newer version.
https://django-import-export.readthedocs.io/en/latest/release_notes.html#export-format
Hopefully updating django-import-export fixes these issues.
Or not. I got that backwards, they didn't change the behavior. Either way though this is apparently "intended" django-import-export behavior for some reason.
We realistically cannot touch the version of django-import-export until a breaking change release. And we have to be very careful about changing any core behavior also. We need to do a whole audit around domains since it isn't domain aware.