Replace knex.fn.now() in DB queries (#10736)

This commit is contained in:
ian
2021-12-29 00:03:03 +08:00
committed by GitHub
parent 341c266e58
commit 8a0fba0691
2 changed files with 5 additions and 5 deletions

View File

@@ -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();

View File

@@ -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'));