How to enforced not to run update,delete query without condition ?
See original GitHub issueIssue type:
[x] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Hi I am new to typeorm, as I learning how to use, I see that I can easily make a mistake (like typo, misunderstand api,…) when I write update or delete query using query builder and it run without where condition and end up with all data getting updated or deleted. So my question is that in typeorm is there any option or a hacky way that when a update or delete query running without a where condition it will throw error to prevent these kind of mistake for newbie ?. Thank you
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
Just for context, it’s possible to unintentionally delete the entire table by providing arguments to .delete() in a wrong format: #6620
@hong-duc To answer your question directly, TypeORM does not have any sort of developer safety functionality built into it, you could probably write your own validation/restriction logic, but this could end up being very cumbersome and ultimately may not make a lot of sense for your use case.