From 65e58b53d805deb4f50abc35cad306131bd2df06 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 26 May 2024 21:14:02 +0200 Subject: [PATCH] events-backend: fix for subscription failing if there are no events Signed-off-by: Patrik Oldsberg --- .../events-backend/src/service/hub/DatabaseEventBusStore.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts b/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts index 9248e1c0e5..0a8dddfe51 100644 --- a/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts +++ b/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts @@ -392,7 +392,9 @@ export class DatabaseEventBusStore implements EventBusStore { id, updated_at: this.#db.fn.now(), topics, - read_until: this.#db(TABLE_EVENTS).max('id') as any, // TODO: figure out TS, + read_until: this.#db.raw( + `( SELECT COALESCE(MAX("id"), 0) FROM "${TABLE_EVENTS}" )`, + ), }) .onConflict('id') .merge(['topics', 'updated_at'])