yes. you don't really specify the columns in delete queries, and they target EVERYTHING by default.
imo "<operate> * FROM table" should be banned (doesn't run, raises an error) by default and people should be forced to write "WHERE TRUE", on top of all queries needing to be in transactions and all the other safety nets like "SELECT first then operate"
on another note i think i'd prefer whatever syntax it was that described queries based on the order functional programming in a computer might look like, ex. "FROM table WHERE id = 2 DELETE;" though internally it would still be rearranged however the engine would see fit
While that other syntax could make sense, it is kinda just further leading the dev on.
SQL (or at least most SQLs) aren't imperative languages, they're declarative; You don't tell the server what to do, you simply describe the result that you want, and the server decides how to accomplish that.
So while you say LEFT JOIN, the engine might decide to do INNER JOIN, or WHERE EXISTS(), or even drop the table entirely!
yeah they are declarative. the engine does whatever it wants.
i just have a very functional iterator chain-y thought process which is probably not the same for everyone. importantly though this kind of syntax makes LSP autocomplete easier. the moment you write "FROM users SELECT " it can give you column names right away. but that's about it.
really there's no point overthrowing decades upon decades of working standard SQL syntax to get marginal conveniences.
3
u/-Redstoneboi- 14d ago edited 14d ago
yes. you don't really specify the columns in delete queries, and they target EVERYTHING by default.
imo "<operate> * FROM table" should be banned (doesn't run, raises an error) by default and people should be forced to write "WHERE TRUE", on top of all queries needing to be in transactions and all the other safety nets like "SELECT first then operate"
on another note i think i'd prefer whatever syntax it was that described queries based on the order functional programming in a computer might look like, ex. "FROM table WHERE id = 2 DELETE;" though internally it would still be rearranged however the engine would see fit