News for hackers. Stuff that matters.
Re:Show HN: Ultimate Plumber – a tool for writing Linux pipe... by yread on Wednesday October 24, 2018 @04:09PM (#18295892)
It's a pity you can't do something similar to SQL: when writing UPDATE/DELETE always write the WHERE clause first
Re:Show HN: Ultimate Plumber – a tool for writing Linux pipe... by rmetzler on Wednesday October 24, 2018 @04:16PM (#18295946)
Something I learned early on when writing possible dangerous SQL selects:

  CREATE TABLE mytable_backup AS SELECT * FROM mytable;
  SELECT * FROM mytable WHERE condition;
  DELETE FROM mytable WHERE condition;
Re:Show HN: Ultimate Plumber – a tool for writing Linux pipe... by traviscj on Thursday October 25, 2018 @03:41AM (#18299188)
Or just let the DB work for you with BEGIN; + (select/update/delete) + COMMIT; or ROLLBACK;
Re:Show HN: Ultimate Plumber – a tool for writing Linux pipe... by jolmg on Wednesday October 24, 2018 @04:18PM (#18295960)
What I like about SQL is that it's got the double safety of ";". To accidentally run a SQL statement before it's ready in a command line, you'd have to both add the ";" AND hit Enter, or have the bad practice of adding ";" before the statement is ready, or use a bad SQL command line that sees the ";" as optional.
Re:Show HN: Ultimate Plumber – a tool for writing Linux pipe... by groestl on Wednesday October 24, 2018 @05:00PM (#18296339)
I always start a session with BEGIN, write UPDATEs/DELETEs as SELECTs first and (if possible) use a staging database until I'm fine with the result.
Re:Show HN: Ultimate Plumber – a tool for writing Linux pipe... by amalcon on Wednesday October 24, 2018 @10:49PM (#18298263)
In SQL, you can at least wrap the whole thing in a transaction. Then, just roll the whole thing back if anything came out wrong.
Re:Show HN: Ultimate Plumber – a tool for writing Linux pipe... by inopinatus on Thursday October 25, 2018 @02:59AM (#18299024)
I usually SELECT COUNT(*) WHERE ..., and only subsequently overwrite with DELETE.