WIP: SQL Formatter

From: Dave Page <dpage(at)pgadmin(dot)org>
To: pgadmin-hackers <pgadmin-hackers(at)lists(dot)postgresql(dot)org>
Subject: WIP: SQL Formatter
Date: 2020-07-29 16:04:00
Message-ID: CA+OCxozz_5+ZGCkpjzYjtoEx_K_8_t4ES5NKzd6S+=JXBZrY-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

The attached WIP patch adds a menu option to the Query Tool to format the
SQL in the editor. It does so per options that can be set in the
Preferences panel (essentially, most of these:
https://sqlparse.readthedocs.io/en/latest/api/#formatting-of-sql-statements)

Some thoughts before I continue:

- There are already options for tabs vs spaces and tab width for the query
tool. At the moment I've intentionally kept separate settings for the same
thing in the formatter. If we use the same options it'll mean that
configuration for formatting is split across two places in the Preferences
panel. On the other hand, it may be handy to have separate options. What do
others think?

- I'm thinking that maybe we should push all user-visible generated SQL
through the formatter. This would essentially mean that all get_sql and
similar functions would call it. We'd probably need to make the re-sql test
suite call it as well. Does this seem like a good idea? It's be a fairly
widespread change, but it would mean that the resql and generated crud
statements would be consistently formatted, to the user's preferences.

Thanks.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EDB: http://www.enterprisedb.com

Attachment Content-Type Size
RM2042.diff application/octet-stream 10.0 KB

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Aditya Toshniwal 2020-07-30 05:28:47 Re: WIP: SQL Formatter
Previous Message Shubham Agarwal 2020-07-29 13:03:00 Sonarqube fixes - test_utils.py