aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-20 10:24:58 +0200
committerChocobozzz <me@florianbigard.com>2020-04-20 10:24:58 +0200
commit8f31261f77c6e521917b3f629b223ccc8df50960 (patch)
tree4ccc77d0c58a5589c87f75686d51c036a099e915 /server/models
parent6ed2e4eaf37a0328001e0040e30f12ca02814ce9 (diff)
downloadPeerTube-8f31261f77c6e521917b3f629b223ccc8df50960.tar.gz
PeerTube-8f31261f77c6e521917b3f629b223ccc8df50960.tar.zst
PeerTube-8f31261f77c6e521917b3f629b223ccc8df50960.zip
Fix videos languages filter SQL query
Diffstat (limited to 'server/models')
-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