Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
fix: escapes sequelize literal query params
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajpiar committed Sep 7, 2020
1 parent b1b4c32 commit 7bec56b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/services/storage/hooks/offers.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import BillingPlan from '../models/billing-plan.model'
import { disallow, discard } from 'feathers-hooks-common'
import Agreement from '../models/agreement.model'
import { hooks } from 'feathers-sequelize'
import { Op } from 'sequelize'
import Sequelize from 'sequelize/lib/sequelize'
import { Op, literal, Sequelize } from 'sequelize'
import dehydrate = hooks.dehydrate

export default {
Expand Down Expand Up @@ -59,10 +58,11 @@ export default {
}

if (totalCapacity) {
const rawQ = 'cast(totalCapacity as integer) BETWEEN ' +
totalCapacity.min + ' AND ' + totalCapacity.max
context.params.sequelize.where.totalCapacity =
Sequelize.literal(rawQ)
const sequelize = context.app.get('sequelize') as Sequelize
const minCap = sequelize.escape(totalCapacity.min)
const maxCap = sequelize.escape(totalCapacity.max)
const rawQ = `cast(totalCapacity as integer) BETWEEN ${minCap} AND ${maxCap}`
context.params.sequelize.where.totalCapacity = literal(rawQ)
}

if (periods?.length) {
Expand Down

0 comments on commit 7bec56b

Please sign in to comment.