No announcement yet.

Use pretty print for view definitions

  • Filter
  • Time
  • Show
Clear All
new posts

  • Use pretty print for view definitions


    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:

    pg_get_viewdef(view_oid, pretty_bool)
    (see ).

    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:

    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:

      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.