mycli icon indicating copy to clipboard operation
mycli copied to clipboard

Update without where clause might need to be executed as destructive command

Open jhonesk opened this issue 5 years ago • 2 comments

I started testing the tool and have been loving it! I wonder if there is any studying around the possibility of making update queries that does not have any where clauses (and therefore alter all table registries), be identified and executed as destructive commands, because it is certainly one of the most effective ways to mess up a table.

I also would like to know where can I find a documentation listing the criteria for executing a query as a destructive command, or the commands itself; in a way that I don't have to test every single scenario that comes to mind. I looked it up and found nothing.

Thank you in advance!

jhonesk avatar Apr 05 '19 16:04 jhonesk

We have a very simple keyword match to determine if query may be "destructive":

https://github.com/dbcli/mycli/blob/efa6b250fcf8a4b7a92c2c880636429536dd9dba/mycli/packages/parseutils.py#L206-L209

It's not very smart. It can definitely be made smarter.

j-bennet avatar Apr 05 '19 16:04 j-bennet

I see.. Well, for now I added 'update' to that; not the best solution, but it's better to be safe than sorry. Thanks for your answer!

jhonesk avatar Apr 05 '19 18:04 jhonesk