Monday, 5 August 2019

Sequelize and NOT operator

Hi all,I have to run this by the community to check whether this is an issue with my code, or with sequelize.I have to transform a SQL-like filter into a sequelize filter object. The translation is for the most part correct, however, one thing I ran into is a peculiar behaviour of sequelize when it encounters [Op.not] in the filter object.The filter in question looks something like: 'condition_a AND NOT(condition_b OR condition_c). When translated to sequelize object, it looks like this:{ jsonField: { [Op.and]: [ condition_a, [Op.not]: { [Op.or]: [ condition_b, condition_c ] } ] }} However, when inspecting the generated query, it appears as if the [Op.not] contents are ignored, i.e. the filter is 'condition_a AND jsonField != {}'.Am I incorrectly using the Op.not symbol, or is there a known issue with it wrapping other filters?

Submitted August 05, 2019 at 11:08AM by MrDilbert

No comments:

Post a Comment