Skip to content

Bugfix: Allow empty arrays and objects in json type fields when inserting data into datastore#4826

Merged
wardi merged 3 commits intockan:masterfrom
Icontech:4766-allow-empty-arrays-and-objects-in-json-fields-with-datastore_create
Jun 14, 2019
Merged

Bugfix: Allow empty arrays and objects in json type fields when inserting data into datastore#4826
wardi merged 3 commits intockan:masterfrom
Icontech:4766-allow-empty-arrays-and-objects-in-json-fields-with-datastore_create

Conversation

@Icontech
Copy link
Copy Markdown
Contributor

@Icontech Icontech commented Jun 3, 2019

Fixes #4766

Proposed fixes:

Add bugfix from #1776 to INSERT method in upsert_data. This allows empty json arrays or json objects to be inserted into json type fields when creating new data in the datastore.

Features:

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

Please [X] all the boxes above that apply

Icontech added 3 commits May 29, 2019 19:13
…tore_create

Currently, adding an empty array or an empty object to a field of type json using datastore_create results in a validation error and status code 409.

After this change, empty arrays and empty objects can be added to fields of type json.
@Icontech
Copy link
Copy Markdown
Contributor Author

Icontech commented Jun 5, 2019

The test failing is test_calculate_record_count in test_create.py. The response from 'when_was_last_analyze' is None but should be an array with data.
I've been trying to recreate this error myself by running the tests on my branch, with no luck. I get an array back containing information about when the resource was created. I've tried changing the test to use json fields with empty arrays as values, but same result.
Perhaps someone with more insight into the code base could take a look or give me some advice?

@wardi
Copy link
Copy Markdown
Contributor

wardi commented Jun 5, 2019

@davidread looks like this test was added in 8aa298d any ideas?

@davidread
Copy link
Copy Markdown

Sadly this test is slightly flaky :(

I've rerun the tests and they pass this time.

@wardi wardi merged commit 7fd6ca6 into ckan:master Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when posting empty array with type json using datastore_create

3 participants