Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/model/query/form-attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ const _get = (exec, options) => {
SELECT datasets.id, MAX("loggedAt") AS "lastAudit" FROM audits
JOIN datasets ON audits."acteeId" = datasets."acteeId"
${actorId == null ? sql`` : sql`
-- We're always interested in dataset.create and dataset.update
-- actions, even for ownerOnly datasets.
-- We're always interested in dataset.create and in actions that add
-- or delete entity properties -- even for ownerOnly datasets.
WHERE
(NOT datasets."ownerOnly") OR
audits.action IN ('dataset.create', 'dataset.update')
audits.action IN ('dataset.create', 'dataset.update', 'dataset.update.property.delete')
`}
GROUP BY datasets.id
) AS audit_metadata ON audit_metadata.id = datasets.id
Expand Down
17 changes: 17 additions & 0 deletions test/integration/api/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -7064,6 +7064,23 @@ describe('datasets and entities', () => {
(await getHash(asChelsea)).should.not.equal(originalHash);
}));

it('changes hash after a dataset property is deleted', testServiceFullTrx(async (service) => {
const [asAlice, asChelsea] = await service.login(['alice', 'chelsea']);
await createData(asAlice);
await assignToProject(asAlice, asChelsea, 'formfill');

// Add an entity property.
await asAlice.post('/v1/projects/1/datasets/people/properties')
.send({ name: 'foo' })
.expect(200);
const originalHash = await getHash(asChelsea);

// Delete the property.
await asAlice.delete('/v1/projects/1/datasets/people/properties/foo')
.expect(200);
(await getHash(asChelsea)).should.not.equal(originalHash);
}));

it('computes hash based on timestamps and the entity count', testServiceFullTrx(async (service, container) => {
const [asAlice, asChelsea] = await service.login(['alice', 'chelsea']);
await createData(asAlice);
Expand Down