pgadmin-org / pgadmin-org/pgadmin4

Undocumented changes to SQL formatting make the feature unusable for me

Open
#7,276 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Waiting for upstream
Dominant language
Python
Stars
3.8k
Forks
891
Avg merge
4d 7h
Merged PRs (30d)
8

Description

This is a follow up to https://github.com/pgadmin-org/pgadmin4/issues/7268

Code formatting has been broken for me since the release v8.3, when it started adding line breaks I do not want, without an obvious way to stop that. Nothing in the release notes. Nothing in the manual.
I want:

SELECT id, col1, col2, col3, metric
FROM  (
   SELECT id, col1, col2, col3
        , min(amount) <> max(amount) AS a_diff, bool_or(true) FILTER (WHERE amount IS NULL) AS a_null
        , min(brand)  <> max(brand)  AS b_diff, bool_or(true) FILTER (WHERE brand  IS NULL) AS b_null
   FROM   tbl
   GROUP  BY id
   ) t
JOIN   LATERAL (
   VALUES
     ('Amount', a_diff, a_null)
   , ('Brand' , b_diff, b_null)
   ) x(metric, diff, has_null) ON (diff OR NOT diff AND has_null)
ORDER  BY id, col;

But [ctrl][shift][K] now produces:

SELECT
   id,
   col1,
   col2,
   col3,
   metric
FROM
   (
      SELECT
         id,
         col1,
         col2,
         col3,
         min(amount) <> max(amount) AS a_diff,
         bool_or(TRUE) FILTER (
            WHERE
               amount IS NULL
         ) AS a_null,
         min(brand) <> max(brand) AS b_diff,
         bool_or(TRUE) FILTER (
            WHERE
               brand IS NULL
         ) AS b_null
      FROM
         tbl
      GROUP BY
         id
   ) t
   JOIN LATERAL (
      VALUES
         ('Amount', a_diff, a_null),
         ('Brand', b_diff, b_null)
   ) x (metric, diff, has_null) ON (
      diff
      OR NOT diff
      AND has_null
   )
ORDER BY
   id,
   col;

Don't want to offend anyone's formatting preferences, but this is unhelpful noise for me. I need an option to disable adding newlines and indentation. Maybe two separate options. Or just stop adding either, altogether. Any way to get capitalization without adding the noise - like it was before

I attached a screenshot of my settings in Preferences → Query Tool → SQL formatting I don't think I am missing something?

erwin_pgadmin_settings_sql_formatting

BTW, "Query Tool", but "ERD tool". Etc. Capitalization of setting names is inconsistent across the board. Consistent capitalization would inspire more clarity and confidence. Noting this here where the screenshot demonstrates my case (as a side-effect). Should I create another issue?

Regards
Erwin

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Query Tool SQL formatting preferences and the follow-up issue 7268, then trace how the Ctrl+Shift+K formatting action applies those settings. Done means users can preserve capitalization while disabling unwanted newlines and indentation, with the requested preference behavior documented and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python, sql
Domain
databases, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.