diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/initializers/database.ts | 1 | ||||
-rw-r--r-- | server/models/pod/pod.ts | 9 | ||||
-rw-r--r-- | server/models/request/request-to-pod.ts | 2 | ||||
-rw-r--r-- | server/models/request/request-video-event.ts | 4 | ||||
-rw-r--r-- | server/models/request/request-video-qadu.ts | 4 | ||||
-rw-r--r-- | server/models/request/request.ts | 4 | ||||
-rw-r--r-- | server/models/user/user.ts | 2 | ||||
-rw-r--r-- | server/models/video/video.ts | 10 |
8 files changed, 20 insertions, 16 deletions
diff --git a/server/initializers/database.ts b/server/initializers/database.ts index b410b0c18..dfad01581 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts | |||
@@ -64,6 +64,7 @@ const sequelize = new Sequelize(dbname, username, password, { | |||
64 | port: CONFIG.DATABASE.PORT, | 64 | port: CONFIG.DATABASE.PORT, |
65 | benchmark: isTestInstance(), | 65 | benchmark: isTestInstance(), |
66 | isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE, | 66 | isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE, |
67 | operatorsAliases: false, | ||
67 | 68 | ||
68 | logging: (message: string, benchmark: number) => { | 69 | logging: (message: string, benchmark: number) => { |
69 | let newMessage = message | 70 | let newMessage = message |
diff --git a/server/models/pod/pod.ts b/server/models/pod/pod.ts index 6619726af..6b33336b8 100644 --- a/server/models/pod/pod.ts +++ b/server/models/pod/pod.ts | |||
@@ -130,7 +130,7 @@ incrementScores = function (ids: number[], value: number) { | |||
130 | const options = { | 130 | const options = { |
131 | where: { | 131 | where: { |
132 | id: { | 132 | id: { |
133 | $in: ids | 133 | [Sequelize.Op.in]: ids |
134 | } | 134 | } |
135 | }, | 135 | }, |
136 | // In this case score is a literal and not an integer so we do not validate it | 136 | // In this case score is a literal and not an integer so we do not validate it |
@@ -178,6 +178,7 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta | |||
178 | let start = Math.floor(Math.random() * count) - limit | 178 | let start = Math.floor(Math.random() * count) - limit |
179 | if (start < 0) start = 0 | 179 | if (start < 0) start = 0 |
180 | 180 | ||
181 | const subQuery = `(SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins})` | ||
181 | const query = { | 182 | const query = { |
182 | attributes: [ 'id' ], | 183 | attributes: [ 'id' ], |
183 | order: [ | 184 | order: [ |
@@ -187,7 +188,7 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta | |||
187 | limit: limit, | 188 | limit: limit, |
188 | where: { | 189 | where: { |
189 | id: { | 190 | id: { |
190 | $in: Sequelize.literal(`(SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins})`) | 191 | [Sequelize.Op.in]: Sequelize.literal(subQuery) |
191 | } | 192 | } |
192 | } | 193 | } |
193 | } | 194 | } |
@@ -201,7 +202,9 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta | |||
201 | listBadPods = function () { | 202 | listBadPods = function () { |
202 | const query = { | 203 | const query = { |
203 | where: { | 204 | where: { |
204 | score: { $lte: 0 } | 205 | score: { |
206 | [Sequelize.Op.lte]: 0 | ||
207 | } | ||
205 | } | 208 | } |
206 | } | 209 | } |
207 | 210 | ||
diff --git a/server/models/request/request-to-pod.ts b/server/models/request/request-to-pod.ts index 6678ed290..4e14e918b 100644 --- a/server/models/request/request-to-pod.ts +++ b/server/models/request/request-to-pod.ts | |||
@@ -41,7 +41,7 @@ removeByRequestIdsAndPod = function (requestsIds: number[], podId: number) { | |||
41 | const query = { | 41 | const query = { |
42 | where: { | 42 | where: { |
43 | requestId: { | 43 | requestId: { |
44 | $in: requestsIds | 44 | [Sequelize.Op.in]: requestsIds |
45 | }, | 45 | }, |
46 | podId: podId | 46 | podId: podId |
47 | } | 47 | } |
diff --git a/server/models/request/request-video-event.ts b/server/models/request/request-video-event.ts index d7dce9bc8..8954407e1 100644 --- a/server/models/request/request-video-event.ts +++ b/server/models/request/request-video-event.ts | |||
@@ -111,7 +111,7 @@ listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: numbe | |||
111 | model: RequestVideoEvent['sequelize'].models.Pod, | 111 | model: RequestVideoEvent['sequelize'].models.Pod, |
112 | where: { | 112 | where: { |
113 | id: { | 113 | id: { |
114 | $in: podIds | 114 | [Sequelize.Op.in]: podIds |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
@@ -135,7 +135,7 @@ removeByRequestIdsAndPod = function (ids: number[], podId: number) { | |||
135 | const query = { | 135 | const query = { |
136 | where: { | 136 | where: { |
137 | id: { | 137 | id: { |
138 | $in: ids | 138 | [Sequelize.Op.in]: ids |
139 | } | 139 | } |
140 | }, | 140 | }, |
141 | include: [ | 141 | include: [ |
diff --git a/server/models/request/request-video-qadu.ts b/server/models/request/request-video-qadu.ts index 9c97812b9..93cf249b3 100644 --- a/server/models/request/request-video-qadu.ts +++ b/server/models/request/request-video-qadu.ts | |||
@@ -101,7 +101,7 @@ listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: numbe | |||
101 | model: RequestVideoQadu['sequelize'].models.Pod, | 101 | model: RequestVideoQadu['sequelize'].models.Pod, |
102 | where: { | 102 | where: { |
103 | id: { | 103 | id: { |
104 | $in: podIds | 104 | [Sequelize.Op.in]: podIds |
105 | } | 105 | } |
106 | } | 106 | } |
107 | }, | 107 | }, |
@@ -122,7 +122,7 @@ removeByRequestIdsAndPod = function (ids: number[], podId: number) { | |||
122 | const query = { | 122 | const query = { |
123 | where: { | 123 | where: { |
124 | id: { | 124 | id: { |
125 | $in: ids | 125 | [Sequelize.Op.in]: ids |
126 | }, | 126 | }, |
127 | podId | 127 | podId |
128 | } | 128 | } |
diff --git a/server/models/request/request.ts b/server/models/request/request.ts index b4c0226fa..71118a947 100644 --- a/server/models/request/request.ts +++ b/server/models/request/request.ts | |||
@@ -88,7 +88,7 @@ listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: numbe | |||
88 | model: Request['sequelize'].models.Pod, | 88 | model: Request['sequelize'].models.Pod, |
89 | where: { | 89 | where: { |
90 | id: { | 90 | id: { |
91 | $in: podIds | 91 | [Sequelize.Op.in]: podIds |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } | 94 | } |
@@ -112,7 +112,7 @@ removeWithEmptyTo = function () { | |||
112 | const query = { | 112 | const query = { |
113 | where: { | 113 | where: { |
114 | id: { | 114 | id: { |
115 | $notIn: [ | 115 | [Sequelize.Op.notIn]: [ |
116 | Sequelize.literal('SELECT "requestId" FROM "RequestToPods"') | 116 | Sequelize.literal('SELECT "requestId" FROM "RequestToPods"') |
117 | ] | 117 | ] |
118 | } | 118 | } |
diff --git a/server/models/user/user.ts b/server/models/user/user.ts index f8598c40f..074c9c121 100644 --- a/server/models/user/user.ts +++ b/server/models/user/user.ts | |||
@@ -271,7 +271,7 @@ loadByUsernameOrEmail = function (username: string, email: string) { | |||
271 | const query = { | 271 | const query = { |
272 | include: [ { model: User['sequelize'].models.Author, required: true } ], | 272 | include: [ { model: User['sequelize'].models.Author, required: true } ], |
273 | where: { | 273 | where: { |
274 | $or: [ { username }, { email } ] | 274 | [Sequelize.Op.or]: [ { username }, { email } ] |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 6c0db59f3..27f59f3a9 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -1012,7 +1012,7 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s | |||
1012 | } | 1012 | } |
1013 | } else if (field === 'tags') { | 1013 | } else if (field === 'tags') { |
1014 | const escapedValue = Video['sequelize'].escape('%' + value + '%') | 1014 | const escapedValue = Video['sequelize'].escape('%' + value + '%') |
1015 | query.where['id'].$in = Video['sequelize'].literal( | 1015 | query.where['id'][Sequelize.Op.in] = Video['sequelize'].literal( |
1016 | `(SELECT "VideoTags"."videoId" | 1016 | `(SELECT "VideoTags"."videoId" |
1017 | FROM "Tags" | 1017 | FROM "Tags" |
1018 | INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId" | 1018 | INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId" |
@@ -1023,19 +1023,19 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s | |||
1023 | // FIXME: Include our pod? (not stored in the database) | 1023 | // FIXME: Include our pod? (not stored in the database) |
1024 | podInclude.where = { | 1024 | podInclude.where = { |
1025 | host: { | 1025 | host: { |
1026 | $iLike: '%' + value + '%' | 1026 | [Sequelize.Op.iLike]: '%' + value + '%' |
1027 | } | 1027 | } |
1028 | } | 1028 | } |
1029 | podInclude.required = true | 1029 | podInclude.required = true |
1030 | } else if (field === 'author') { | 1030 | } else if (field === 'author') { |
1031 | authorInclude.where = { | 1031 | authorInclude.where = { |
1032 | name: { | 1032 | name: { |
1033 | $iLike: '%' + value + '%' | 1033 | [Sequelize.Op.iLike]: '%' + value + '%' |
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | } else { | 1036 | } else { |
1037 | query.where[field] = { | 1037 | query.where[field] = { |
1038 | $iLike: '%' + value + '%' | 1038 | [Sequelize.Op.iLike]: '%' + value + '%' |
1039 | } | 1039 | } |
1040 | } | 1040 | } |
1041 | 1041 | ||
@@ -1056,7 +1056,7 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s | |||
1056 | function createBaseVideosWhere () { | 1056 | function createBaseVideosWhere () { |
1057 | return { | 1057 | return { |
1058 | id: { | 1058 | id: { |
1059 | $notIn: Video['sequelize'].literal( | 1059 | [Sequelize.Op.notIn]: Video['sequelize'].literal( |
1060 | '(SELECT "BlacklistedVideos"."videoId" FROM "BlacklistedVideos")' | 1060 | '(SELECT "BlacklistedVideos"."videoId" FROM "BlacklistedVideos")' |
1061 | ) | 1061 | ) |
1062 | } | 1062 | } |