Repository navigation
fix(types): correct typing definitions for Sequelize.where - #14018
Conversation
- string is not accepted in `leftOperand` - `rightOperand` is operator-dependant - `operator` can only be a symbol
sdepold
left a comment
There was a problem hiding this comment.
Tbh... I didn't even know that you can pass anything other than an object to where 🙈 so you have my trust
|
It's for those couple use-cases where you need to use Before merging, I'll re-add Edit: that is now done |
wbourne0
left a comment
There was a problem hiding this comment.
I haven't used where as a function personally, but the types look fine and I trust your judgement so lgtm.
|
Thanks :) Here we go then |
Co-authored-by: Sascha Depold <[email protected]>
Co-authored-by: Sascha Depold <[email protected]>
Co-authored-by: Sascha Depold <[email protected]>
|
🎉 This PR is included in version 7.0.0-alpha.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…ze#14018) Co-authored-by: Sascha Depold <[email protected]>
…ze#14018) Co-authored-by: Sascha Depold <[email protected]>
Pull Request Checklist
npm run testornpm run test-DIALECTpass with this change (including linting)?Description Of Change
The typings for
Sequelize.where(leftOperand, operator, rightOperand)were very incorrect:operatoraccepted strings. It works but users should use Op symbols. I can revert this change but the typing would not be great.rightOperandwere all over the place. I've now delegated them toWhereOperatorssowhereaccepts the same values as the POJO version.i.e. in
where(col('first_name'), Op.iLike, name),namewill be accept the exact same values as{ firstName: { [Op.iLike]: name } }.The signature used to be
where(attribute, comparator, logic)but I've renamed it towhere(leftOperand, operator, rightOperand)which is much closer to reality as the operands can be much more than just an attribute.I've also added tests for things the JSDoc says are supported but were not tested.
I have not updated the typings for
lib/utils/Whereas it's internal and the changes I want to make would impact a lot more files - but I'd like to refactor it for v7 in #13782