Swirrl / datahost-prototypes

Eclipse Public License 1.0
0 stars 0 forks source link

Incorrect metadata fetched for empty revision #307

Closed xdrcft8000 closed 10 months ago

xdrcft8000 commented 10 months ago

the bug meant that when sending a GET request on an empty revision (with no child changes) you would get the metadata for every change in the database.

this was because the optional query in 'get-revison' in cb.clj would fail when a revision has no changes: [:optional [[revision-uri :dh/hasChange '?change]

this means that the variable '?change is unassigned.

a later optional query: [:optional ['?change :dh/revisionSnapshotCSV '?snapshot]] works fine if '?change has been assigned to a change. However when unassigned it simply retrieves every triple with the revisionSnapshotCSV predicate

my suggested fix is to include the latter query in the same optional block. SPARLQ will only execute the second part if the first part succeeds:

[:optional [[revision-uri :dh/hasChange '?change] ['?change :dh/revisionSnapshotCSV '?snapshot]]]