Re: last comma inside "CREATE TABLE ()" statements

Поиск
Список
Период
Сортировка
От will trillich
Тема Re: last comma inside "CREATE TABLE ()" statements
Дата
Msg-id 20010426235655.D21240@serensoft.com
обсуждение исходный текст
Ответ на Re: last comma inside "CREATE TABLE ()" statements  ("Rod Taylor" <rod.taylor@inquent.com>)
Список pgsql-general
On Thu, Apr 26, 2001 at 10:38:42AM -0400, Rod Taylor wrote:
> Gah.. just put comma's at the beginning...

Oh, now THAT's intuitive:

    . To be
    , or not to be
    , that is the question
    . Whether 'tis nobler...

Charming. :)

> SELECT bleah
>   , blah
>   , otherthing
> FROM arghh
>   , feh
>   , fah
> WHERE ( blah in ('1'
> , '2'
> , '3')
> OR otherthing IS TRUE
> )
> OR bleah IS FALSE
>
> Oh, and indent nicer.  You can remove virtually any line (except the
> ones with commands in them) without any issues.

What that does, is it transfers the location of the problem. Now
the comma is effectively in FRONT of most terms, except the
FIRST.

An alternative compromise:

    select
        first
        ,
        second
        ,
        third
        ,
        fourth
    from
        alpha
        ,
        bravo
        ,
        charlie
    ;

It's odd to use a whole line just for a florkin' comma, but in vi
"2ddkkP" or "2ddjjjjP" will rearrange things nicely, while
keeping the purists at bay (not to mention any names, but You
Know Who You Are :).

I'd still prefer to ALLOW (but not DEMAND) 'empty after last
comma'. Or if you're determined to go for 'empty before first
comma':

    update tbl
        set
            ,one   = something
            ,two   = something-else
            ,three = fn('hgttg',42)
            ,four  = that
        ;

But i hope you'll agree that this is more obtuse than we need to
be. Not to mention the "speedbump" effect it'll have on the person
who's got to look over your code next month.

This looks much nicer, imho --

    update tbl
        set
            one   = something       ,
            two   = something-else  ,
            three = fn('hgttg',42)  ,
            four  = that            ,
        ;

After all, the comma is of no importance to the conceptual task
we're after: i don't care if there's a token separating those
assignments -- i'm interested in the fields and the values being
assigned to them. The commas are just there to help us predict
that the compiler will understand what we're after.

And it's easy to rearrange those lines in a text editor without
having to be paranoid about "Do i need to add a comma somewhere?
Should i look to see if i should take one out?"

Computers should work. People should think. "Data! Mow the lawn!"

--
don't visit this page. it's bad for you. take my expert word for it.
http://www.salon.com/people/col/pagl/2001/03/21/spring/index1.html

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

В списке pgsql-general по дате отправления:

Предыдущее
От: will trillich
Дата:
Сообщение: Re: Classes of returned rows
Следующее
От: Anand Raman
Дата:
Сообщение: Re: Data Export from PostGreSQL