[ckan-dev] datastore upsert api

Sam Leitner sam.leitner at gmail.com
Wed Jun 24 20:41:13 UTC 2015


Hi all,

I'm having trouble using the datastore_upsert API. I get complaints from
CKAN about needing a unique key to update:

 [error] [client 10.0.2.2] File
'/usr/lib/ckan/default/src/ckan/ckanext/datastore/db.py', line 664 in
upsert_data
[error] [client 10.0.2.2]   'table': [u'table does not have a unique key
defined']
[error] [client 10.0.2.2] ValidationError: None - {'table': [u'table does
not have a unique key defined']}

 but I don't see a parameter in the docs to produce a unique key when
creating the datastore table (
http://docs.ckan.org/en/latest/maintaining/datastore.html#ckanext.datastore.logic.action.datastore_create
indicates that I can create primary_keys, but then I see "AND
idx.indisprimary = false" in datastore/db.py).

Here's a gist of some jinja2 code that produces my problem in the app
(residing in package/snippet/resource_form.html):
https://gist.github.com/sleitner/2c079e435c04afe52c53

And here's a similar gist of curl commands written into a bash script that
you can use to reproduce the issue:
https://gist.github.com/sleitner/e222a0499a8290f64db7

What am I missing?

Thanks for your help!
Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150624/956f14a8/attachment-0002.html>


More information about the ckan-dev mailing list