From d8fb5aeacafd928d2649b1da64eb64815bb73b1e Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Sun, 30 Sep 2018 23:06:42 +0100 Subject: [PATCH] Reject empty changesets --- app/src/building.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/building.js b/app/src/building.js index b9627390..5593c42d 100644 --- a/app/src/building.js +++ b/app/src/building.js @@ -99,8 +99,12 @@ function saveBuilding(building_id, building, user_id) { [building_id, previous_revision_id] ).then(old_building => { const patches = compare(old_building, building, BUILDING_FIELD_WHITELIST); + console.log("Patching", patches) const forward = patches[0]; const reverse = patches[1]; + if (Object.keys(forward).length === 0) { + return Promise.reject("No change provided") + } return t.one( `INSERT INTO logs ( forward_patch, reverse_patch, building_id, user_id @@ -111,6 +115,7 @@ function saveBuilding(building_id, building, user_id) { [forward, reverse, building_id, user_id] ).then(revision => { const sets = db.$config.pgp.helpers.sets(forward); + console.log("Setting", sets) const check_revision = (previous_revision_id)? "AND revision_id = $4" : ""; return t.one( `UPDATE