Thread: Format SQL (external tool)

Format SQL (external tool)

From
Shane StClair
Date:
Hi list,

Just suggesting an idea. It would be really nice to be able to configure an external command to format SQL in pgAdmin. After configuring the external tool path in prefs, user hits a key combo (Shift-Ctrl F?) and the highlighted query text (or all text if none highlighted) gets run through the formatter and replaces the original text in the query window. Would be flexible for the user and seems fairly simple to implement in pgAdmin. Just a thought!

Thanks,
Shane

--
Shane StClair
Software Engineer
Axiom Consulting & Design
http://www.axiomalaska.com

Re: Format SQL (external tool)

From
"J.F. Oster"
Date:
Hello Shane,

I'd like to see some code beautifier in PgAdmin too.
Do you already have an eye to a CLI tool for this job?

I saw Free SQL Formatter (http://fsqlf.sourceforge.net/) under LGPL,
which seems ok. May be, we can adopt it as a built-in default
formatter (hope it will compile under MacOS, Solaris and FreeBSD).
If things go well, it can be developed to support Postgre's SQL
extensions and PL/pgSQL constructs as well.

In short, seems a good idea to me, I could participate in it's
implementation :)

P.S. Should this be posted to [pgadmin-hackers]?

Saturday, February 1, 2014, 2:17:20 AM, you wrote:
SS> Hi list,

SS> Just suggesting an idea. It would be really nice to be able
SS> to configure an external command to format SQL in pgAdmin. After
SS> configuring the external tool path in prefs, user hits a key combo
SS> (Shift-Ctrl F?) and the highlighted query text (or all text if
SS> none highlighted) gets run through the formatter and replaces the
SS> original text in the query window. Would be flexible for the user
SS> and seems fairly simple to implement in pgAdmin. Just a thought!


-- 
Best regards,J.F.





Re: Format SQL (external tool)

From
Shane StClair
Date:
Good idea, I'll switch this over to pgadmin-hackers. Thanks.


On Sat, Feb 1, 2014 at 10:06 AM, J.F. Oster <jinfroster@mail.ru> wrote:
Hello Shane,

I'd like to see some code beautifier in PgAdmin too.
Do you already have an eye to a CLI tool for this job?

I saw Free SQL Formatter (http://fsqlf.sourceforge.net/) under LGPL,
which seems ok. May be, we can adopt it as a built-in default
formatter (hope it will compile under MacOS, Solaris and FreeBSD).
If things go well, it can be developed to support Postgre's SQL
extensions and PL/pgSQL constructs as well.

In short, seems a good idea to me, I could participate in it's
implementation :)

P.S. Should this be posted to [pgadmin-hackers]?

Saturday, February 1, 2014, 2:17:20 AM, you wrote:
SS> Hi list,

SS> Just suggesting an idea. It would be really nice to be able
SS> to configure an external command to format SQL in pgAdmin. After
SS> configuring the external tool path in prefs, user hits a key combo
SS> (Shift-Ctrl F?) and the highlighted query text (or all text if
SS> none highlighted) gets run through the formatter and replaces the
SS> original text in the query window. Would be flexible for the user
SS> and seems fairly simple to implement in pgAdmin. Just a thought!


--
Best regards,
 J.F.





--
Shane StClair
Software Engineer
Axiom Consulting & Design
http://www.axiomalaska.com

Re: Format SQL (external tool)

From
Michal Kozusznik
Date:
We are using SQL Assistant for a lot of tasks like code formatting, Autocomplete, code searching etc. Really powerful tool.
Unfortunately pgAdmin developers has been rejected my request to make CTRL-space hotkey optional in pgAdmin. Allegedly because of amount of work needed to do it (lol).
I wouldn't count on any cooperation from pgadmin dev team. sad.

On 31.1.2014 23:17, Shane StClair wrote:
Hi list,

Just suggesting an idea. It would be really nice to be able to configure an external command to format SQL in pgAdmin. After configuring the external tool path in prefs, user hits a key combo (Shift-Ctrl F?) and the highlighted query text (or all text if none highlighted) gets run through the formatter and replaces the original text in the query window. Would be flexible for the user and seems fairly simple to implement in pgAdmin. Just a thought!

Thanks,
Shane

--
Shane StClair
Software Engineer
Axiom Consulting & Design
http://www.axiomalaska.com

Attachment

Re: Format SQL (external tool)

From
Craig Ringer
Date:
On 02/06/2014 06:25 PM, Michal Kozusznik wrote:
> We are using SQL Assistant for a lot of tasks like code formatting,
> Autocomplete, code searching etc. Really powerful tool.
> Unfortunately pgAdmin developers has been rejected my request to make
> CTRL-space hotkey optional in pgAdmin. Allegedly because of amount of
> work needed to do it (lol).
> I wouldn't count on any cooperation from pgadmin dev team. sad.

I'd like to remind you that PgAdmin-III is open source.

You are free to develop and contribute features that you feel are
desirable.

Sometimes this may involve revisions to the way they're implemented, and
sometimes the project may choose not to accept a patch, but usually
it'll be received with a grateful "thanks, that's handy".

-- Craig Ringer                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services



Re: Format SQL (external tool)

From
Guillaume Lelarge
Date:
On Thu, 2014-02-06 at 20:34 +0800, Craig Ringer wrote:
> On 02/06/2014 06:25 PM, Michal Kozusznik wrote:
> > We are using SQL Assistant for a lot of tasks like code formatting,
> > Autocomplete, code searching etc. Really powerful tool.
> > Unfortunately pgAdmin developers has been rejected my request to make
> > CTRL-space hotkey optional in pgAdmin. Allegedly because of amount of
> > work needed to do it (lol).
> > I wouldn't count on any cooperation from pgadmin dev team. sad.
> 
> I'd like to remind you that PgAdmin-III is open source.
> 
> You are free to develop and contribute features that you feel are
> desirable.
> 
> Sometimes this may involve revisions to the way they're implemented, and
> sometimes the project may choose not to accept a patch, but usually
> it'll be received with a grateful "thanks, that's handy".
> 

Cannot agree more. Thanks, Craig.


-- 
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com