3 ms·
I guess trailing commas would make constructing the clauses programatically a little easier, if they are being appended one-by-one. On the downside, does this
by f4c39012 2y ago
I guess trailing commas would make constructing the clauses programatically a little easier, if they are being appended one-by-one.
On the downside, does this make it easier to write code that is vulnerable to command injection, because it is easier to append a bunch of statements passed as input?
For the WHERE clause, if i happen to be programatically appending conditions, i'll start with `WHERE true` so i don't need to consider if i'm appending the first condition (no AND/OR/NOT etc.) or a later condition (required AND/OR/NOT etc.). A decent query planner should ignore the fixed value.
- citrin_ru 2y agoProgrammatically it is easy to not add trailing comma (just use something like `join(',', array)`) but it would save time during manual editing of a long query - I often add a new line then run query to discover that I forgot to add , on a previous line. When each line including the last one ends with , I can just add a new line (also ending with ,) and save time.