Skip to content
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

[#5452] allow lists in resource extras #5453

Merged
merged 5 commits into from
Jun 23, 2020
Merged

Conversation

wardi
Copy link
Contributor

@wardi wardi commented Jun 18, 2020

Fixes #5452

Proposed fixes:

remove two lines of code from resource_dict_save. This allows ckanext-scheming and other extensions to have repeating subfields and other list values in their resource schemas without hacks like converting to/from JSON (resource extras are already stored in the DB as JSON)

Features:

  • includes tests covering changes
  • includes updated documentation
  • includes user-visible changes
  • includes API changes
  • includes bugfix for possible backport

@wardi
Copy link
Contributor Author

wardi commented Jun 19, 2020

One more small change was added here. In current versions of ckan dicts passed as resource extras were being stored as their python repr, e.g. "{u'mykey': u'myvalue'}" even though the lower level JsonDict field was capable of storing actual JSON. I've added an extras_valid_json validator instead of the validator that was turning objects into their python repr.

@wardi
Copy link
Contributor Author

wardi commented Jun 19, 2020

resource extra value (JSON) returned value before returned value after
"text" "text" ✔️ "text" ✔️
42 "42" 42 ✔️
{"test": "value"} "{u'test': u'value'}" {"test": "value"} ✔️
true "True" true ✔️
null "None" null ✔️
[1, 2, 3] (silently removed) ❌ [1, 2, 3] ✔️

I think this can be considered a bug fix, the current behaviour is very strange for a JSON API

@amercader
Copy link
Member

@wardi I had to tweak this a bit to adapt it to the old way validators where handled in the schema in 2.7, do you mind having an extra quick look at these to make sure nothing seems off? thanks

85656ba...8fc5ceb

@amercader amercader deleted the 5452-resource-extra-lists branch July 23, 2020 10:20
@wardi
Copy link
Contributor Author

wardi commented Jul 23, 2020

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lists not allowed as resource extras
3 participants