[ckan-dev] Deleting non-empty vocabularies via API3

Sean Hammond sean.hammond at okfn.org
Tue Nov 13 10:35:48 UTC 2012


> when I try to delete a non-empty tag vocabulary via the API (through
> HTTP), I get an internal server error. Checking the logs, this turns
> out to be a consistency error raised by  sqlalchemy:
> 
> Error - <class 'sqlalchemy.exc.IntegrityError'>: (IntegrityError)
> update or delete on table "vocabulary" violates foreign key constraint
> "tag_vocabulary_id_fkey" on table "tag" DETAIL:  Key
> (id)=(21421955-7560-467c-af30-9f790b73e6ae) is still referenced from
> table "tag".  'DELETE FROM vocabulary WHERE vocabulary.id = %(id)s'
> {'id': u'21421955-7560-467c-af30-9f790b73e6ae'} URL:
> http://33.33.33.10:5000/api/action/vocabulary_delete
> 
> The error makes sense, but I'm wondering if it would be useful to
> extend the API to also allow the deletion of non-empty vocabularies,
> possibly via a parameter (not sure what best practice in API design
> is). At the very least, it would be cool if the error message coming
> back in the response had more information in it.

Thanks Knud, looks like a bug and I would be happy with either of your
suggested solutions. Fortunately it's easy to workaround for the time
being by always deleting all a vocabulary's tags before deleting the
vocabulary itself. I've made a ticket for it so it doesn't get
forgotten:

http://trac.ckan.org/ticket/3014




More information about the ckan-dev mailing list