aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/models/video/video-query-builder.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/server/models/video/video-query-builder.ts b/server/models/video/video-query-builder.ts
index 015bf43de..8f0a814de 100644
--- a/server/models/video/video-query-builder.ts
+++ b/server/models/video/video-query-builder.ts
@@ -207,15 +207,14 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
207 const languagesQueryParts: string[] = [] 207 const languagesQueryParts: string[] = []
208 208
209 if (languages.length !== 0) { 209 if (languages.length !== 0) {
210 languagesQueryParts.push('("video"."language" IN (:languageOneOf)') 210 languagesQueryParts.push('"video"."language" IN (:languageOneOf)')
211 replacements.languageOneOf = languages 211 replacements.languageOneOf = languages
212 212
213 languagesQueryParts.push( 213 languagesQueryParts.push(
214 ' EXISTS (' + 214 'EXISTS (' +
215 ' SELECT 1 FROM "videoCaption" WHERE "videoCaption"."language" ' + 215 ' SELECT 1 FROM "videoCaption" WHERE "videoCaption"."language" ' +
216 ' IN (' + createSafeIn(model, languages) + ') AND ' + 216 ' IN (' + createSafeIn(model, languages) + ') AND ' +
217 ' "videoCaption"."videoId" = "video"."id"' + 217 ' "videoCaption"."videoId" = "video"."id"' +
218 ' )' +
219 ')' 218 ')'
220 ) 219 )
221 } 220 }
@@ -224,7 +223,9 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
224 languagesQueryParts.push('"video"."language" IS NULL') 223 languagesQueryParts.push('"video"."language" IS NULL')
225 } 224 }
226 225
227 and.push(languagesQueryParts.join(' OR ')) 226 if (languagesQueryParts.length !== 0) {
227 and.push('(' + languagesQueryParts.join(' OR ') + ')')
228 }
228 } 229 }
229 230
230 // We don't exclude results in this if so if we do a count we don't need to add this complex clauses 231 // We don't exclude results in this if so if we do a count we don't need to add this complex clauses