Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility rulesToQuery with Sequelize 5 #171

Closed
bbones opened this issue Mar 26, 2019 · 3 comments
Closed

Incompatibility rulesToQuery with Sequelize 5 #171

bbones opened this issue Mar 26, 2019 · 3 comments
Labels

Comments

@bbones
Copy link

bbones commented Mar 26, 2019

The result of function based on String doesn't work with { where: query } statement for example in a scope definition

Workaround based on Security part of http://docs.sequelizejs.com/manual/querying.html#combinations
You need to use operatorsAliases

`
const Op = Sequelize.Op;
const operatorsAliases = {
$eq: Op.eq,
$ne: Op.ne,
$gte: Op.gte,
$gt: Op.gt,
$lte: Op.lte,
$lt: Op.lt,
$not: Op.not,
$in: Op.in,
$notIn: Op.notIn,
$is: Op.is,
$like: Op.like,
$notLike: Op.notLike,
$iLike: Op.iLike,
$notILike: Op.notILike,
$regexp: Op.regexp,
$notRegexp: Op.notRegexp,
$iRegexp: Op.iRegexp,
$notIRegexp: Op.notIRegexp,
$between: Op.between,
$notBetween: Op.notBetween,
$overlap: Op.overlap,
$contains: Op.contains,
$contained: Op.contained,
$adjacent: Op.adjacent,
$strictLeft: Op.strictLeft,
$strictRight: Op.strictRight,
$noExtendRight: Op.noExtendRight,
$noExtendLeft: Op.noExtendLeft,
$and: Op.and,
$or: Op.or,
$any: Op.any,
$all: Op.all,
$values: Op.values,
$col: Op.col
};

const connection = new Sequelize(db, user, pass, { operatorsAliases });`

@stalniy
Copy link
Owner

stalniy commented Mar 26, 2019

rulesToQuery was implemented as a generic helper function which result must be transformed according to ORM or db driver rules.

CASL has never officially supported sequelize or SQL (#8), so it's not an issue.

@stalniy
Copy link
Owner

stalniy commented Mar 26, 2019

I close this but feel free to reopen if you think I can do something on this

@stalniy stalniy closed this as completed Mar 26, 2019
@stalniy
Copy link
Owner

stalniy commented Jun 14, 2019

Please look at this discussion about sequelize aliases: sequelize/sequelize#10820 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants