From 8a0fba0691d5bce752a27343e367208dfce659a2 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 29 Dec 2021 00:03:03 +0800 Subject: [PATCH] Replace knex.fn.now() in DB queries (#10736) --- api/src/services/authentication.ts | 6 +++--- api/src/services/shares.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/services/authentication.ts b/api/src/services/authentication.ts index 1f648e0134..521711a733 100644 --- a/api/src/services/authentication.ts +++ b/api/src/services/authentication.ts @@ -275,12 +275,12 @@ export class AuthenticationService { .leftJoin('directus_shares AS d', 's.share', 'd.id') .joinRaw('LEFT JOIN directus_roles AS r ON r.id IN (u.role, d.role)') .where('s.token', refreshToken) - .andWhere('s.expires', '>=', this.knex.fn.now()) + .andWhere('s.expires', '>=', new Date()) .andWhere((subQuery) => { - subQuery.whereNull('d.date_end').orWhere('d.date_end', '>=', this.knex.fn.now()); + subQuery.whereNull('d.date_end').orWhere('d.date_end', '>=', new Date()); }) .andWhere((subQuery) => { - subQuery.whereNull('d.date_start').orWhere('d.date_start', '<=', this.knex.fn.now()); + subQuery.whereNull('d.date_start').orWhere('d.date_start', '<=', new Date()); }) .first(); diff --git a/api/src/services/shares.ts b/api/src/services/shares.ts index 721046ec74..1a47686532 100644 --- a/api/src/services/shares.ts +++ b/api/src/services/shares.ts @@ -54,10 +54,10 @@ export class SharesService extends ItemsService { .from('directus_shares') .where('id', payload.share) .andWhere((subQuery) => { - subQuery.whereNull('date_end').orWhere('date_end', '>=', this.knex.fn.now()); + subQuery.whereNull('date_end').orWhere('date_end', '>=', new Date()); }) .andWhere((subQuery) => { - subQuery.whereNull('date_start').orWhere('date_start', '<=', this.knex.fn.now()); + subQuery.whereNull('date_start').orWhere('date_start', '<=', new Date()); }) .andWhere((subQuery) => { subQuery.whereNull('max_uses').orWhere('max_uses', '>=', this.knex.ref('times_used'));