public inbox for [email protected]  
help / color / mirror / Atom feed
From: Raffi Holzer <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: Autoformatting
Date: Wed, 15 Feb 2017 09:39:44 -0500
Message-ID: <CAF+OSJuZF5o-Odfh4oN5afsxWFE9Jv4_053Uct+YxOzRy5unuw@mail.gmail.com> (raw)
In-Reply-To: <CA+OCxoxdhH=ygL062Ey5kGGvcnP0timUqBppVH9r3oPQart3fA@mail.gmail.com>
References: <CAF+OSJsUY01H6T7EOKO+AzN9Rt-BekzxCWWP47jWGC+mSi2sPA@mail.gmail.com>
	<CA+OCxowyMCS4DJBWm1sN-iAudt05Bii88mbxu-SPXRAK35S7jA@mail.gmail.com>
	<CAF+OSJvuDCOKMihuR0-WoJekG+S9P+Dd8tM9Ukqan5dKnXcBcA@mail.gmail.com>
	<CA+OCxoxdhH=ygL062Ey5kGGvcnP0timUqBppVH9r3oPQart3fA@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Thanks Dave! We came to the same conclusion about a button press. And thank
you for the SQL guidelines.

On Wed, Feb 15, 2017 at 4:37 AM, Dave Page <[email protected]> wrote:

> Hi
>
> On Tue, Feb 14, 2017 at 3:02 PM, Raffi Holzer <[email protected]> wrote:
> > Hi Dave,
> >  When we were talking about auto formatting we were actually referring
> to a
> > single button press doing all of these things to a large block of text.
> The
> > use case here would be if you receive a large illegible query and paste
> it
> > into the query editor it would either automatically auto-format or you
> would
> > press a button and it would auto-format.
>
> Oh, OK.
>
> > We are trying to determine a few
> > things. One, are there preferred formatting guidelines
>
> Hmm, it seems I missed SQL when I wrote our (basic) coding standards:
> https://www.pgadmin.org/docs4/1.x/coding_standards.html
>
> By default (in my opinion), we should have 4 character indents, new
> lines for logically distinct objects (e.g. columns or constraints on a
> table), commas etc. at the end of the line, keywords in upper case,
> e.g.
>
> SELECT
>     a,
>     b,
> FROM
>     t
> ORDER BY
>     a,
>     b;
>
> However, that obviously becomes unwieldy in some cases, so common
> sense is needed:
>
> SELECT
>     a, b,
> FROM
>     t
> ORDER BY
>     a, b;
>
> There should of course be a limit on the number of columns listed per
> line - but should the limit be a count or max width in chars? With a
> CREATE TABLE statement I think it's clear that each column should be
> on it's own line:
>
> CREATE TABLE t (
>     a serial NOT NULL PRIMARY KEY,
>     b text
> );
>
> In other words, we need to define (or adopt) a formal standard for
> this, and then write a parser/formatter - which seems like a decidedly
> non-trivial amount of work (FYI, I tried the Python format-sql module,
> and it failed on ~80% of my tests - probably either because it doesn't
> understand COPY or pl/pgsql).
>
> > and two, how should
> > this autoformatting be implemented? On a button press? Upon pasting in
> the
> > text?
>
> Definitely not on pasting - if you drop in a large script, it could
> take far too long, plus you may not care, or be looking at the
> original source in another tool and trying to mentally reconcile lines
> or statements to each other. I would say it should be a
> button/shortcut.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>



-- 
Raffi Holzer
Product Manager
Pivotal Labs


view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Autoformatting
  In-Reply-To: <CAF+OSJuZF5o-Odfh4oN5afsxWFE9Jv4_053Uct+YxOzRy5unuw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox