[ckan-dev] datastore upsert api
Sam Leitner
sam.leitner at gmail.com
Tue Jul 14 19:40:07 UTC 2015
Right, and annoyingly it looks like I need to name all previous
columns/fields when using _create to make a new one?
Also, it looks like the datastore_info API is no longer present in the
code, but is still in the docs?
Thanks,
Sam
On Thu, Jun 25, 2015 at 12:27 AM, Matthew Fullerton <
matt.fullerton at gmail.com> wrote:
> A related problem is that this issue comes up when you try to use the API
> to insert records into a datastore table created by the user
> interface/datapusher. I'm not sure why the automatically created _id column
> cannot be set as the datastore primary key automatically.
>
> As you've probably noticed, I got the impression when experimenting that
> _create doesn't just function as create but also as alter, in the case of
> adding a primary key; the data in the table doesn't get lost.
>
> Best.
> Matt
>
> 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
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150714/cc15ef66/attachment-0002.html>
More information about the ckan-dev
mailing list