Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: query formatting #155

Closed
thousandsofthem opened this issue Jan 8, 2016 · 19 comments
Closed

Feature request: query formatting #155

thousandsofthem opened this issue Jan 8, 2016 · 19 comments

Comments

@thousandsofthem
Copy link

It would be nice to have query formatting button/hotkey
SQLyog, Sequel Pro can do that (also see http://www.dpriver.com/pp/sqlformat.htm)

P.S. also https://github.com/TaoK/PoorMansTSqlFormatter (http://poorsql.com/), http://sqlformat.darold.net/, many more. part of them are opensource

P.P.S. https://github.com/darold/pgFormatter

@JAertgeerts
Copy link

+1: Nice to have

@tmikoss
Copy link

tmikoss commented May 30, 2016

Would very much appreciate such feature. I use Postico to debug queries generated by ORM, and a single button press to convert the huge one-liner into a structured query would be greatly appreciated.

@sul4bh
Copy link

sul4bh commented Jun 3, 2016

My vote +1

@firedev
Copy link

firedev commented Oct 14, 2016

sqlformat.org has an api that can be used if nothing else fits https://sqlformat.org/api/

For what it's worth I am using Alfred with Format SQL Workflow

@gajus
Copy link

gajus commented Apr 15, 2017

For the record, https://sequelpro.com/ is using the API approach to format queries.

It is a bit annoying UX, though since every time you want to format the query they prompt a dialog asking to give permission to send the query to external web service. If this to become a feature in this way, there should be a toggle to remember the selection.

@jakob
Copy link
Owner

jakob commented Jun 22, 2017

I really don't want to use a web API for formatting queries -- code is private data, and shouldn't be shared needlessly with 3rd parties. Also, performance would be unpredictable, and it would require a network connection.

But I just discovered pgFormatter , a Perl based SQL formatting tool for PostgreSQL. Maybe I can use that to format queries!

You can try pgFormatter here: http://sqlformat.darold.net

@gajus
Copy link

gajus commented Jun 22, 2017

Yeah, pgFormatter is quite good. I am using it in my Node.js projects, via https://github.com/gajus/pg-formatter.

@reganjohnson
Copy link

Would like to see this also. Options on the formatting would be nice (I prefer to work in lowercase, personally.)

@josestbernard
Copy link

+1

@DeMol-EE
Copy link

Any update on this feature?

@jetbrand
Copy link

I'm using "Automator".
Select sql text and execute created Automator service.

@techkeyur
Copy link

Auto-format or hotkey would be awesome +1 from me

@yiichou
Copy link

yiichou commented Nov 12, 2019

+1

2 similar comments
@ynelin
Copy link

ynelin commented Nov 12, 2019

+1

@freddiev4
Copy link

👍

@robsalasco
Copy link

waiting for this feature!!

@rmonteiro89
Copy link

+1

@jakob
Copy link
Owner

jakob commented Apr 16, 2020

Hi! I just wanted to let you know that Postico 2 now has query formatting built in!

(We already added the feature a few weeks ago, but I forgot to update this thread. My apologies)

Our solution was to bundle pgFormatter with Postico, so we can format queries locally without sending anything to a web service.

You can trigger the new formatter with the shortcut ctrl-F. By default the current statement is formatted, but you can select more than one statement to format multiple statements at once.

Download the latest preview build of Postico 2 here: https://eggerapps.at/postico2/

@aristocrates
Copy link

aristocrates commented Oct 4, 2021

Is there a way to disable (or change) ctrl-F to format a query in postico 2? This collides with ctrl-F to move forward one character

Edit: I worked around it by choosing a different key combination for the shortcut per https://eggerapps.at/postico/docs/v1.5.19/keyboard-shortcuts.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests