Announcement

Collapse
No announcement yet.

Use pretty print for view definitions

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use pretty print for view definitions

    Hi,

    when clicking on 'Design View' Navicat displays the view definition. Unfortunately you display the unprettified version. So the definition contains a lot of unnecessary braces which make it very hard to read the SQL code and to make modifications. Note that there exists a function in Postgres which can prettify the view definition:

    Code:
    pg_get_viewdef(view_oid, pretty_bool)
    (see https://www.postgresql.org/docs/curr...-CATALOG-TABLE ).

    What you currently display is identical to pg_get_viewdef(..., false).

    It would be very nice, if you could instead display pg_get_viewdef(..., true). Currently this function removes at least all unnecessary braces, making the code much more readable.

    Here is a little example. What Navicat displays:

    Code:
    SELECT (((((a.a + b.b) + c.c) + d.d) + e.e) + f.f) AS result,
        ((b.b * c.c) * d.d) AS result2
       FROM (((((myschema.a
         JOIN myschema.b ON ((a.a = b.a)))
         JOIN myschema.c ON ((a.a = c.a)))
         JOIN myschema.d ON ((a.a = d.a)))
         JOIN myschema.e ON ((a.a = e.a)))
         JOIN myschema.f ON ((a.a = f.a)))
    What pg_get_viewdef(..., true) displays:

    Code:
      SELECT a.a + b.b + c.c + d.d + e.e + f.f AS result,
        b.b * c.c * d.d AS result2
       FROM myschema.a
         JOIN myschema.b ON a.a = b.a
         JOIN myschema.c ON a.a = c.a
         JOIN myschema.d ON a.a = d.a
         JOIN myschema.e ON a.a = e.a
         JOIN myschema.f ON a.a = f.a;
    Last edited by moorhuhnfreak; 08-08-2018, 07:19 AM.

  • #2
    Hi moorhuhnfreak,

    Thanks for your suggestion. I have forwarded your request to the development team. We will keep improving Navicat in future.

    Comment

    Working...
    X