Re: IN clause behaving badly with missing comma and line break
От | Francisco Olarte |
---|---|
Тема | Re: IN clause behaving badly with missing comma and line break |
Дата | |
Msg-id | CA+bJJbw=RvKYrespkhD5+=y8SmVXmhtewhaf2MbfVAb2wV6NQQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: IN clause behaving badly with missing comma and line break (Philip Semanchuk <philip@americanefficient.com>) |
Ответы |
Re: IN clause behaving badly with missing comma and line break
|
Список | pgsql-bugs |
On Wed, 18 Jan 2023 at 16:21, Philip Semanchuk <philip@americanefficient.com> wrote: > .... We’ve adopted a formatting standard that helps us to avoid surprises due to missing commas. We put one string literalon each line and place the commas all in the same column with a significant amount of white space to the left of thecommas. With this safeguard in place, it’s very easy to spot a missing comma. > > WHERE t IN ('a' , > 'foo' , > 'bar' , > ) I believe that one is a syntax error ( last comma ). I use a slightly different one, I put commas before the second and subsequent elements. WHERE t IN ( 'a' , 'foo' , 'bar' ) Both in SQL and in other languages with list constructs. I switched to that a couple decades ago as many languages do not allow a trailing comma in literal lists, and .. - Adding/deleting a first value is rarer ( in my experience ) than adding/deleting a last one. With the comma first you only edit two lines when adding/deleting the first one ( commas last means you have to do it when touching the last ). Same can be said when moving lines around using cut & paste, you only have to touch the lines contents when moving the first one. - Commas line up without worrying about padding when constants have different lenghts. Also I do not have to worry if a line goes of the edge due to narrow editor windows. - I look more to the beginning of the lines than the end, so spotting missing commas is easier ( for me ). - Looks pretty to me :-p I uses it a lot in SQL, specially for field lists in DML, as I tend to put them in several lines, and found it better ( for me ) then commas last. Francisco Olarte.
В списке pgsql-bugs по дате отправления: