From bae616273d455d225d131eb17c56db6c20a0b6b3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 5 May 2022 10:29:35 +0200 Subject: Convert followers/following in raw SQL queries Prevent weird bug in SQL generation --- server/models/video/sql/video/videos-id-list-query-builder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/models/video') diff --git a/server/models/video/sql/video/videos-id-list-query-builder.ts b/server/models/video/sql/video/videos-id-list-query-builder.ts index 09cb791db..8692a436a 100644 --- a/server/models/video/sql/video/videos-id-list-query-builder.ts +++ b/server/models/video/sql/video/videos-id-list-query-builder.ts @@ -2,7 +2,7 @@ import { Sequelize } from 'sequelize' import validator from 'validator' import { exists } from '@server/helpers/custom-validators/misc' import { WEBSERVER } from '@server/initializers/constants' -import { buildDirectionAndField, createSafeIn } from '@server/models/utils' +import { buildDirectionAndField, createSafeIn, parseRowCountResult } from '@server/models/utils' import { MUserAccountId, MUserId } from '@server/types/models' import { VideoInclude, VideoPrivacy, VideoState } from '@shared/models' import { AbstractRunQuery } from '../../../shared/abstract-run-query' @@ -105,7 +105,7 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery { countVideoIds (countOptions: BuildVideosListQueryOptions): Promise { this.buildIdsListQuery(countOptions) - return this.runQuery().then(rows => rows.length !== 0 ? rows[0].total : 0) + return this.runQuery().then(rows => parseRowCountResult(rows)) } getQuery (options: BuildVideosListQueryOptions) { -- cgit v1.2.3