Re: [pgadmin-hackers] Autoformatting
От | Dave Page |
---|---|
Тема | Re: [pgadmin-hackers] Autoformatting |
Дата | |
Msg-id | CA+OCxoyw+TA8A8nyAD=JSTz4dSyzcMtYMDhzjX1mLxsUe+HgNQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [pgadmin-hackers] Autoformatting (Robert Eckhardt <reckhardt@pivotal.io>) |
Ответы |
Re: [pgadmin-hackers] Autoformatting
|
Список | pgadmin-hackers |
On Mon, May 8, 2017 at 3:50 PM, Robert Eckhardt <reckhardt@pivotal.io> wrote:
Over the weekend I created some options for formatting. certainly this isn't complete but I hope it is a good starting point for the conversation. Copy and paste lost syntax highlighting but please assume that will be included./* Unformatted */select distinct dep.deptype,dep.classid,coalesce(coc.relname, clrw.relname) as ownertable from pg_depend dep left join pg_class cl on dep.objid = cl.oidleft join pg_attribute att on dep.objid = att.attrelid and dep.objsubid = att.attnumwhere dep.objid = 16385 :: oid and classid in (select oid from pg_classwhere relname in ( 'pg_class', 'pg_constraint' )) order by classid,cl.relkin;/* Keywords Upper, Stacked, commas after */SELECT DISTINCT dep.deptype,dep.classid,Coalesce(coc.relname, clrw.relname) AS ownertableFROM pg_depend depleft join pg_class clON dep.objid = cl.oidleft join pg_attribute attON dep.objid = att.attrelidAND dep.objsubid = att.attnumWHERE dep.objid = 16385 :: oidAND classid IN (SELECT oidFROM pg_classWHERE relname IN ( 'pg_class', 'pg_constraint' ))ORDER BY classid,cl.relkin;
Snipping the rest, as I think 'commas before' are the work of Chthulu. Aside from the fact that they look ugly, the whole point of a comma is to denote a pause/separation after a word.
Anyhoo, The standard we try to use in pgAdmin at the moment is slightly different from the example you've given. To add it into the mix...
/* Keywords Upper, 4 space indent, commas after, AND/OR after,
* no spaces after ( or before ), or around ::
*/
SELECT DISTINCT
dep.deptype,
dep.classid,
coalesce(coc.relname, clrw.relname) AS ownertable
FROM
pg_depend dep
LEFT JOIN pg_class cl ON dep.objid = cl.oid
LEFT JOIN pg_attribute att ON dep.objid = att.attrelid AND dep.objsubid = att.attnum
WHERE
dep.objid = 16385::oid AND
classid IN (
SELECT
oid
FROM
pg_class
WHERE
relname IN ('pg_class', 'pg_constraint')
)
ORDER BY
classid,
cl.relkind;
There are some subtleties that are open to personal taste there;
- Formatting of the sub-select - e.g. should the SELECT directly follow the (, and should the rest be indented accordingly?
- Formatting of multiple quals in the joins; e.g. should the qual following the AND be on the next line, and if so, should it be indented one level, or to align with the qual above? Should the first qual be on the next line?
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
В списке pgadmin-hackers по дате отправления: