dlcs/elucidate-server

sql error when deleting annotations

Closed this issue · 0 comments

Deleting an annotation throws an error.
How to reproduce

curl-vvvv  -XDELETE -H 'If-Match: d5a1fabad9dee27a122e9ee2356c7498' http://localhost:8080/annotation/w3c/speech-music/1b7409c4-ecfe-40e2-8212-90ef522d2826

Expected results
Annotation is deleted
Actual results
Following SQL error is thrown:

PreparedStatementCallback; bad SQL grammar [SELECT * FROM annotation_delete(?, ?)]; nested exception is org.postgresql.util.PSQLException: ERROR: structure of query does not match function result type
  Detail: Number of returned columns (8) does not match expected column count (10).
  Where: PL/pgSQL function annotation_delete(character varying,character varying) line 22 at RETURN QUERY

Version
1.5.1 from dlcs/elucidate-server docker hub image.
Additional Info
The column mismatch is due to the annotation_delete procedure:

RETURN QUERY
SELECT
a.annotationid,
a.cachekey,
ac.collectionid,
a.createddatetime,
a.deleted,
a.json,
a.modifieddatetime,
a.id
FROM

Missing the ownerid and group_ids columns defined in the new annotation_get procedure from the security migration:

There are a couple of other SETOF annotation_get uses that are probably also affected.

Related to #100 which also fixes some SQL. Should fixes like this be bundled into a new migration?