You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The formatting of the View editor is not retained between editing sessions.
This is especially annoying when it moves things that were put on separate lines for complex joins or concat and make them single lined and hard to read / see.
To Reproduce
Open the View Editor and us the automatic formatting CTRL + K.
Save
Open the View Editor again and the formatting has been lost.
As a follow up to this, I have noticed in the latest version 9.14 that just using the auto formatting for the View editor will cause the view editor to throw an error and not let you save.
Opened a view, used ctrl + K for formatting, tried to Save:
Here are the formatting rules that are currently set.
The error when saving after Ctrl+K is fixed in #10591. The dialog checks whether an edited definition changes the view's columns by comparing the text before FROM, and that comparison was case-sensitive, so the formatter changing the case of function names, types or keywords looked like a column change and triggered the drop-and-recreate warning. The comparison now ignores case and formatting (outside quoted identifiers and string literals).
Keeping your own formatting between edits isn't something pgAdmin can do, unfortunately. PostgreSQL doesn't store the text of a view's definition: it stores the parsed query, and pg_get_viewdef() rebuilds the SQL from that every time it's read, so line breaks, indentation and comments are lost as soon as the view is saved, whichever tool created it. The usual workaround is to keep the formatted source in a file or in version control.
The follow-up bug, where reformatting a view's SQL was treated as a column change that dropped and re-created the view, is fixed in 3530761 (#10591).
Keeping the view's original formatting isn't possible, however: PostgreSQL doesn't store the text of the view definition, only its parsed form, and pgAdmin reads it back with pg_get_viewdef(), which regenerates the SQL in PostgreSQL's own layout. Any formatting applied when the view was created is lost on the server side before pgAdmin ever sees it.
Activity
TorsionTools commentedon Apr 20, 2026
As a follow up to this, I have noticed in the latest version 9.14 that just using the auto formatting for the View editor will cause the view editor to throw an error and not let you save.
Opened a view, used ctrl + K for formatting, tried to Save:

Here are the formatting rules that are currently set.

Fix formatting a view's SQL being treated as a column change that dro…
Keep quoted identifiers intact and split at the FROM keyword when che…
dpage commentedon Oct 15, 2026
There are two parts to this.
The error when saving after Ctrl+K is fixed in #10591. The dialog checks whether an edited definition changes the view's columns by comparing the text before
FROM, and that comparison was case-sensitive, so the formatter changing the case of function names, types or keywords looked like a column change and triggered the drop-and-recreate warning. The comparison now ignores case and formatting (outside quoted identifiers and string literals).Keeping your own formatting between edits isn't something pgAdmin can do, unfortunately. PostgreSQL doesn't store the text of a view's definition: it stores the parsed query, and
pg_get_viewdef()rebuilds the SQL from that every time it's read, so line breaks, indentation and comments are lost as soon as the view is saved, whichever tool created it. The usual workaround is to keep the formatted source in a file or in version control.Fix formatting a view's SQL being treated as a column change that dro…
Keep quoted identifiers intact and split at the FROM keyword when che…
Make the view reformat test independent of the PostgreSQL version. pg…
Fix formatting a view's SQL being treated as a column change that dro…
Keep quoted identifiers intact and split at the FROM keyword when che…
Make the view reformat test independent of the PostgreSQL version. pg…
Fix formatting a view's SQL being treated as a column change that dro…
Keep quoted identifiers intact and split at the FROM keyword when che…
Make the view reformat test independent of the PostgreSQL version. pg…
Skip SQL comments and dollar-quoted strings when checking view column…
Fix formatting a view's SQL being treated as a column change that dro…
dpage commentedon Oct 15, 2026
The follow-up bug, where reformatting a view's SQL was treated as a column change that dropped and re-created the view, is fixed in 3530761 (#10591).
Keeping the view's original formatting isn't possible, however: PostgreSQL doesn't store the text of the view definition, only its parsed form, and pgAdmin reads it back with
pg_get_viewdef(), which regenerates the SQL in PostgreSQL's own layout. Any formatting applied when the view was created is lost on the server side before pgAdmin ever sees it.dpage commentedon Oct 16, 2026
Closing: the follow-up bug is fixed in 3530761 (#10591), and keeping a view's original formatting isn't possible for the reason above.