From 1c7bed0c1525bfd156eb812ba55d18d31c24de30 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Wed, 1 Sep 2021 20:13:39 +0200 Subject: [PATCH] Fix returning next planned sequence number. If no sequences have been shot, return 1 instead of null as the next available sequence number. Fixes #125. --- lib/www/server/lib/db/plan/lib/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/www/server/lib/db/plan/lib/index.js b/lib/www/server/lib/db/plan/lib/index.js index 4a5f42b..30f7bf7 100644 --- a/lib/www/server/lib/db/plan/lib/index.js +++ b/lib/www/server/lib/db/plan/lib/index.js @@ -36,7 +36,9 @@ async function getSequence (client) { `; const res = await client.query(text); - return res.rows[0] && res.rows[0].sequence; + // If no sequences have been found, assume none have been shot + // and return 1 + return (res.rows[0] && res.rows[0].sequence) || 1; } async function getTimestamps (client, projectId, payload) {