Remove sequelize deprecated operators
authorChocobozzz <florian.bigard@gmail.com>
Thu, 26 Oct 2017 14:59:02 +0000 (16:59 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Thu, 26 Oct 2017 14:59:02 +0000 (16:59 +0200)
client/src/app/videos/+video-edit/video-update.component.ts
server/initializers/database.ts
server/models/pod/pod.ts
server/models/request/request-to-pod.ts
server/models/request/request-video-event.ts
server/models/request/request-video-qadu.ts
server/models/request/request.ts
server/models/user/user.ts
server/models/video/video.ts

index c4ae228962a2fd7d7d504babfaedcaed8f30054b..30390ac058ef23836a9a2f420e6c0bdaa407d383 100644 (file)
@@ -131,4 +131,3 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
     this.form.patchValue(this.video.toJSON())
   }
 }
-
index b410b0c18067879d4828b403434703551e3474b0..dfad01581c199756e9b7300c34348e00cb9383fa 100644 (file)
@@ -64,6 +64,7 @@ const sequelize = new Sequelize(dbname, username, password, {
   port: CONFIG.DATABASE.PORT,
   benchmark: isTestInstance(),
   isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE,
+  operatorsAliases: false,
 
   logging: (message: string, benchmark: number) => {
     let newMessage = message
index 6619726afcf397f1f64e1f6d7b43c14e89d38096..6b33336b8c0f359833290223327474df4015375e 100644 (file)
@@ -130,7 +130,7 @@ incrementScores = function (ids: number[], value: number) {
   const options = {
     where: {
       id: {
-        $in: ids
+        [Sequelize.Op.in]: ids
       }
     },
     // 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
     let start = Math.floor(Math.random() * count) - limit
     if (start < 0) start = 0
 
+    const subQuery = `(SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins})`
     const query = {
       attributes: [ 'id' ],
       order: [
@@ -187,7 +188,7 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta
       limit: limit,
       where: {
         id: {
-          $in: Sequelize.literal(`(SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins})`)
+          [Sequelize.Op.in]: Sequelize.literal(subQuery)
         }
       }
     }
@@ -201,7 +202,9 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta
 listBadPods = function () {
   const query = {
     where: {
-      score: { $lte: 0 }
+      score: {
+        [Sequelize.Op.lte]: 0
+      }
     }
   }
 
index 6678ed290f4fc9ed8a5f999b0efc21bf0bb521b6..4e14e918b5a917627a2424a87440b70253df1cf8 100644 (file)
@@ -41,7 +41,7 @@ removeByRequestIdsAndPod = function (requestsIds: number[], podId: number) {
   const query = {
     where: {
       requestId: {
-        $in: requestsIds
+        [Sequelize.Op.in]: requestsIds
       },
       podId: podId
     }
index d7dce9bc83e0754c836cf021388c740d73471517..8954407e16c932cd9495d630191087a074e8c817 100644 (file)
@@ -111,7 +111,7 @@ listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: numbe
                       model: RequestVideoEvent['sequelize'].models.Pod,
                       where: {
                         id: {
-                          $in: podIds
+                          [Sequelize.Op.in]: podIds
                         }
                       }
                     }
@@ -135,7 +135,7 @@ removeByRequestIdsAndPod = function (ids: number[], podId: number) {
   const query = {
     where: {
       id: {
-        $in: ids
+        [Sequelize.Op.in]: ids
       }
     },
     include: [
index 9c97812b9e3bb4de66eae043b22e6a0abc04e638..93cf249b37e14e693f8a27ab040375e6f0e3d2b4 100644 (file)
@@ -101,7 +101,7 @@ listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: numbe
           model: RequestVideoQadu['sequelize'].models.Pod,
           where: {
             id: {
-              $in: podIds
+              [Sequelize.Op.in]: podIds
             }
           }
         },
@@ -122,7 +122,7 @@ removeByRequestIdsAndPod = function (ids: number[], podId: number) {
   const query = {
     where: {
       id: {
-        $in: ids
+        [Sequelize.Op.in]: ids
       },
       podId
     }
index b4c0226fa6512339b037e59db1b4db05dda015e6..71118a947e30325d8e5971163d0a2771ecc8f632 100644 (file)
@@ -88,7 +88,7 @@ listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: numbe
           model: Request['sequelize'].models.Pod,
           where: {
             id: {
-              $in: podIds
+              [Sequelize.Op.in]: podIds
             }
           }
         }
@@ -112,7 +112,7 @@ removeWithEmptyTo = function () {
   const query = {
     where: {
       id: {
-        $notIn: [
+        [Sequelize.Op.notIn]: [
           Sequelize.literal('SELECT "requestId" FROM "RequestToPods"')
         ]
       }
index f8598c40f4ecca27af4f046576135451faf96fd0..074c9c12143ac388068585a247ec944f2289a78d 100644 (file)
@@ -271,7 +271,7 @@ loadByUsernameOrEmail = function (username: string, email: string) {
   const query = {
     include: [ { model: User['sequelize'].models.Author, required: true } ],
     where: {
-      $or: [ { username }, { email } ]
+      [Sequelize.Op.or]: [ { username }, { email } ]
     }
   }
 
index 6c0db59f322ae0160ff6435fc300dfe3a4e899bd..27f59f3a9c920242ef34cf4d9c7d64f0c0bade34 100644 (file)
@@ -1012,7 +1012,7 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s
     }
   } else if (field === 'tags') {
     const escapedValue = Video['sequelize'].escape('%' + value + '%')
-    query.where['id'].$in = Video['sequelize'].literal(
+    query.where['id'][Sequelize.Op.in] = Video['sequelize'].literal(
       `(SELECT "VideoTags"."videoId"
         FROM "Tags"
         INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId"
@@ -1023,19 +1023,19 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s
     // FIXME: Include our pod? (not stored in the database)
     podInclude.where = {
       host: {
-        $iLike: '%' + value + '%'
+        [Sequelize.Op.iLike]: '%' + value + '%'
       }
     }
     podInclude.required = true
   } else if (field === 'author') {
     authorInclude.where = {
       name: {
-        $iLike: '%' + value + '%'
+        [Sequelize.Op.iLike]: '%' + value + '%'
       }
     }
   } else {
     query.where[field] = {
-      $iLike: '%' + value + '%'
+      [Sequelize.Op.iLike]: '%' + value + '%'
     }
   }
 
@@ -1056,7 +1056,7 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s
 function createBaseVideosWhere () {
   return {
     id: {
-      $notIn: Video['sequelize'].literal(
+      [Sequelize.Op.notIn]: Video['sequelize'].literal(
         '(SELECT "BlacklistedVideos"."videoId" FROM "BlacklistedVideos")'
       )
     }