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

entityManager.delete() proving to be a big footgun #4608

Closed
osdiab opened this issue Aug 19, 2019 · 1 comment
Closed

entityManager.delete() proving to be a big footgun #4608

osdiab opened this issue Aug 19, 2019 · 1 comment

Comments

@osdiab
Copy link
Contributor

osdiab commented Aug 19, 2019

Issue 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)

Steps to reproduce or a small repository showing the problem:

If you do this, what happens?

entityManager.delete(User, { where: { name: "Omar" } });

Answer: It deletes every User in your database, because delete doesn't take FindOptions, and therefore the where key appears to be completely ignored.

This is easily avoidable by using it as the documentation says, and instead doing delete(User, { name: "Omar" }); but since TypeScript won't tell you that you're doing anything wrong due to the overly general types, my team is finding this to be a particularly volatile API choice for TypeORM to not warn against.

Better would be stricter types to forbid usage of keys that aren't a part of User, but as a general complaint, wish the TypeORM APIs just generally had stricter enforcement of a consistent API invocation syntax.

@imnotjames
Copy link
Contributor

Duplicate of #3416

@imnotjames imnotjames marked this as a duplicate of #3416 Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants