ckanext-scheming icon indicating copy to clipboard operation
ckanext-scheming copied to clipboard

Don't store empty repeating subfields

Open amercader opened this issue 1 year ago • 1 comments

When implementing repeating subfields without any mandatory subfields, if empty values are sent from the form an "empty" item is stored, with all its properties empties:

{
    "name": "test-dataset",
    "publisher": [
        {
            "email": "",
            "name": "",
            "type": "",
        }
    ]
}

The changes in expand_form_composite() fix the issue on the scheming side, preparing a data_dict with an empty list for that field:

{
    "name": "test-dataset",
    "publisher": []
}

Sadly, on the CKAN side the navl functions drop the field entirely (somewhere along make_full_schema and get_all_key_combinations) and it doesn't get stored as an extra, so it's missing from the resulting dataset dict.

{
    "name": "test-dataset",
}

@wardi Ideally we would want an empty list in the resulting dataset, but do you think a missing field is an improvement?

amercader avatar Jun 20 '24 09:06 amercader

It would be nicer to be able to store an empty list, but a missing value is an improvement over a list with one object with blank fields for sure.

wardi avatar Jun 20 '24 11:06 wardi