Обсуждение: Feature Request: inline comments

Поиск
Список
Период
Сортировка

Feature Request: inline comments

От
CaT
Дата:
Whilst reading http://www.postgresql.org/docs/8.2/interactive/sql-comment.html
I came across this user comment:

Ricardo Bánffy                        04 Sep 2007 18:15:44

It is a pretty obvious suggestion I bet was made many, many times
before, but it would be very useful if you could create comments while
creating the objects themselves, like

CREATE TABLE FOO (  ID INTEGER NOT NULL PRIMARY KEY COMMENT 'The ID',  VALUE VARCHAR(10) COMMENT 'The value',
) COMMENT 'The table';


This would be a good thing as it would make documenting schemas more
in-your-face and less prone to forgetting (ie, atm, if you do want to
comment on rows you effectively wind up with two table definitions
(kinda)).

Perhaps this is a small enough add to make it into 8.3?

--    "To the extent that we overreact, we proffer the terrorists the   greatest tribute."       - High Court Judge
MichaelKirby
 


Re: Feature Request: inline comments

От
Tom Lane
Дата:
CaT <cat@zip.com.au> writes:
> It is a pretty obvious suggestion I bet was made many, many times
> before, but it would be very useful if you could create comments while
> creating the objects themselves, like

> CREATE TABLE FOO (
>    ID INTEGER NOT NULL PRIMARY KEY COMMENT 'The ID',
>    VALUE VARCHAR(10) COMMENT 'The value',
> ) COMMENT 'The table';

This seems like a fairly bad idea to me, because it converts your table
definitions into proprietary syntax.  Heaven help you trying to load the
above into any other database.  With a separate COMMENT ON command, at
least you have a fighting chance of ignoring the errors and pressing on.

> Perhaps this is a small enough add to make it into 8.3?

Feature freeze was six months ago, and no this wouldn't be a "small
add" even if it was the best idea since sliced bread.
        regards, tom lane


Re: Feature Request: inline comments

От
CaT
Дата:
On Wed, Nov 07, 2007 at 06:32:53PM -0500, Tom Lane wrote:
> CaT <cat@zip.com.au> writes:
> > It is a pretty obvious suggestion I bet was made many, many times
> > before, but it would be very useful if you could create comments while
> > creating the objects themselves, like
> 
> > CREATE TABLE FOO (
> >    ID INTEGER NOT NULL PRIMARY KEY COMMENT 'The ID',
> >    VALUE VARCHAR(10) COMMENT 'The value',
> > ) COMMENT 'The table';
> 
> This seems like a fairly bad idea to me, because it converts your table
> definitions into proprietary syntax.  Heaven help you trying to load the
> above into any other database.  With a separate COMMENT ON command, at
> least you have a fighting chance of ignoring the errors and pressing on.

Well, in a dump of the DB, you could have them as COMMENT ON. Otherwise
I /think/ this should do it in vim at least:

:%s/ COMMENT '\([^']*''\)*[^']*'//

It's not a perfect regex (though I think it could be made to hand E''
escaping) but it'll do for most comments.

> > Perhaps this is a small enough add to make it into 8.3?
> 
> Feature freeze was six months ago, and no this wouldn't be a "small
> add" even if it was the best idea since sliced bread.

Fair cop.

--    "To the extent that we overreact, we proffer the terrorists the   greatest tribute."       - High Court Judge
MichaelKirby
 


Re: Feature Request: inline comments

От
Andrew Dunstan
Дата:

CaT wrote:
> On Wed, Nov 07, 2007 at 06:32:53PM -0500, Tom Lane wrote:
>   
>> CaT <cat@zip.com.au> writes:
>>     
>>> It is a pretty obvious suggestion I bet was made many, many times
>>> before, but it would be very useful if you could create comments while
>>> creating the objects themselves, like
>>>       
>>> CREATE TABLE FOO (
>>>    ID INTEGER NOT NULL PRIMARY KEY COMMENT 'The ID',
>>>    VALUE VARCHAR(10) COMMENT 'The value',
>>> ) COMMENT 'The table';
>>>       
>> This seems like a fairly bad idea to me, because it converts your table
>> definitions into proprietary syntax.  Heaven help you trying to load the
>> above into any other database.  With a separate COMMENT ON command, at
>> least you have a fighting chance of ignoring the errors and pressing on.
>>     
>
> Well, in a dump of the DB, you could have them as COMMENT ON. Otherwise
> I /think/ this should do it in vim at least:
>
> :%s/ COMMENT '\([^']*''\)*[^']*'//
>
> It's not a perfect regex (though I think it could be made to hand E''
> escaping) but it'll do for most comments.
>
>   

No it won't. There's dollar quoting to think of, and multiline comments. 
It all looks like clutter to me anyway.

cheers

andrew


Re: Feature Request: inline comments

От
"Gevik Babakhani"
Дата:
> Feature freeze was six months ago, and no this wouldn't be a 
> "small add" even if it was the best idea since sliced bread.

+1