From 803610ab8294c385c602c159f0d030a69be571dd Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Tue, 27 Jun 2023 12:07:23 +0300 Subject: [PATCH] fix: max revision query order (#4096) --- src/lib/db/event-store.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/db/event-store.ts b/src/lib/db/event-store.ts index e4b55e317d..7af1977027 100644 --- a/src/lib/db/event-store.ts +++ b/src/lib/db/event-store.ts @@ -158,8 +158,11 @@ class EventStore implements IEventStore { async getMaxRevisionId(largerThan: number = 0): Promise { const row = await this.db(TABLE) .max('id') - .whereNotNull('feature_name') - .orWhere('type', SEGMENT_UPDATED) + .where((builder) => + builder + .whereNotNull('feature_name') + .orWhere('type', SEGMENT_UPDATED), + ) .andWhere('id', '>=', largerThan) .first(); return row ? row.max : -1;