From 672f8e3b423814f536e4eaf835a140a3e2074135 Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Thu, 22 Feb 2024 15:53:34 +0100 Subject: [PATCH] chore: filter timestamp on different DB engines Signed-off-by: Marek Libra --- .../src/database/DatabaseNotificationsStore.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts index 8621072834..9b654cfd04 100644 --- a/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts +++ b/plugins/notifications-backend/src/database/DatabaseNotificationsStore.ts @@ -98,6 +98,9 @@ export class DatabaseNotificationsStore implements NotificationsStore { options: NotificationGetOptions | NotificationModifyOptions, ) => { const { user } = options; + const isSQLite = this.db.client.config.client.includes('sqlite3'); + // const isPsql = this.db.client.config.client.includes('pg'); + const query = this.db('notification').where('user', user); if (options.sort !== undefined && options.sort !== null) { @@ -107,7 +110,19 @@ export class DatabaseNotificationsStore implements NotificationsStore { } if (options.createdAfter) { - query.where('created', '>=', options.createdAfter.valueOf()); + if (isSQLite) { + query.where( + 'notification.created', + '>=', + options.createdAfter.valueOf(), + ); + } else { + query.where( + 'notification.created', + '>=', + options.createdAfter.toISOString(), + ); + } } if (options.limit) {