question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to enforced not to run update,delete query without condition ?

See original GitHub issue

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)


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:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
anton-botcommented, Aug 26, 2020

Just for context, it’s possible to unintentionally delete the entire table by providing arguments to .delete() in a wrong format: #6620

1reaction
Destreyfcommented, Jan 11, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prevent or avoid running update delete statements ...
You can write WHERE 1 = 1 or WHERE EMP_ID = EMP_ID or WHERE SYSDATE IS NOT NULL - all three where conditions...
Read more >
Can you prevent deletes and inserts without a WHERE clause ...
No, not exactly. The point is to stop data modifications that would potentially hit the whole table. That would also stop an expensive...
Read more >
Prevent Update or Delete of All Rows in a SQL Server Table
First we will execute a delete statement with a WHERE clause. vendorID. Now to verify the delete prevention of all rows without a...
Read more >
Prevent delete/update without where - MSDN - Microsoft
This approach will require you to write only 2 procs ( 1 for update and 1 for delete ) - revoke all permissions...
Read more >
SA0037 : UPDATE statement without row limiting conditions
The rule looks for UPDATE statements not having WHERE and JOIN clauses. How to fix. Consider reviewing your code to avoid unintentionally updating...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found