An UPDATE without a WHERE, or something close to it
41–50 of 112 posts
Re: An UPDATE without a WHERE, or something close to it
#42With databases, start a transaction first, then update, and look at the number of rows affected. If it's an oh shit moment, rollback, if not commit.
Re: An UPDATE without a WHERE, or something close to it
#43Re: An UPDATE without a WHERE, or something close to it
#44Surely this will become a non-problem as we migrate to NOSQL... no...? oh? we're migrating back? great.
Re: An UPDATE without a WHERE, or something close to it
#45Re: An UPDATE without a WHERE, or something close to it
#46Re: An UPDATE without a WHERE, or something close to it
#47A particularly nasty aspect of SQL UPDATE syntax is the predicate order, i.e. SET is before WHERE. So when you type it in order, there's a dangerous phase you have to go through if you hit enter by accident. Having run an `mkfs.ext3 /dev/sda` (note the missing partition number) by accident, I've learned to start potentially destructive commands by typing first whatever makes that command a comment (# in shell, -- in…
I religiously write it out of order for this reason. The IDE complains for a bit, but it's better to deal with some squiggles for a few seconds until you've filled in the column assignments part.
Re: An UPDATE without a WHERE, or something close to it
#48A particularly nasty aspect of SQL UPDATE syntax is the predicate order, i.e. SET is before WHERE. So when you type it in order, there's a dangerous phase you have to go through if you hit enter by accident. Having run an `mkfs.ext3 /dev/sda` (note the missing partition number) by accident, I've learned to start potentially destructive commands by typing first whatever makes that command a comment (# in shell, -- in…
This problem is fixed in query languages like EdgeQL.[0]
Re: An UPDATE without a WHERE, or something close to it
#49A particularly nasty aspect of SQL UPDATE syntax is the predicate order, i.e. SET is before WHERE. So when you type it in order, there's a dangerous phase you have to go through if you hit enter by accident. Having run an `mkfs.ext3 /dev/sda` (note the missing partition number) by accident, I've learned to start potentially destructive commands by typing first whatever makes that command a comment (# in shell, -- in…
One quick trick I use a lot in the shell is to run a known safe command with the argument first, and then run the dangerous command with the the !$ variable (the last argument of the previous command) so there's no possibility of a mistake in copying and pasting. Something like: `ls /tmp/junk; rm !$`.
$ ls /
$ ls /tmp/junk; rm !$
It's taking "/" rather than "/tmp/junk"..EDIT: formatting
Re: An UPDATE without a WHERE, or something close to it
#50A SQL statement without a WHERE looks too suspicious to me to make a mistake like that.