RE: How to keep format of views source code as entered?

From: "Markhof, Ingolf" <ingolf(dot)markhof(at)de(dot)verizon(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Cc: Christophe Pettus <xof(at)thebuild(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: RE: How to keep format of views source code as entered?
Date: 2021-01-07 17:33:48
Message-ID: b91237db66a5419cac100fd2100f7cb0@MS-FRA-E13EX02.intl.ad.vzwcorp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

So, it looks like PostgreSQL does support saving the original source code of a view.

What's best practise to use as a code repository?

I would expect support of multi-user access, access-right management and perhaps versioning as well…?

Thanks for your help!

Ingolf

From: Markhof, Ingolf [mailto:ingolf(dot)markhof(at)de(dot)verizon(dot)com]
Sent: 07 January 2021 17:19
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: [E] How to keep format of views source code as entered?

Hi!

Switching from Oracle SLQ to PostgreSQL I am facing the issue that the SQL code the system returns when I open a views source code is different from the code I entered. The code is formatted differently, comments are gone and e.g. all text constants got an explicit cast to ::text added. (see sample below).

I want the SLQ code of my views stored as I entered it. Is there any way to achieve this? Or will I be forced to maintain my views SQL code outside of PostgreSQL views?

Any hints welcome!

Here is an example:

I enter this code to define a simple view:

create or replace view myview as
select
product_id,
product_acronym
from
products -- my comment here
where
product_acronym = 'ABC'
;

However, when I open the view my SQL client (DBeaver) again, this is what I get:

CREATE OR REPLACE VIEW myview
AS SELECT product_id,
product_acronym
FROM products
WHERE product_acronym = 'ABC'::text;

So, the formatting changed, keywords are capitalized, the comment I added in the from-part has gone and the text constant 'ABC' changed to 'ABC'::text.

Verizon Deutschland GmbH - Sebrathweg 20, 44149 Dortmund, Germany - Amtsgericht Dortmund, HRB 14952 - Geschäftsführer: Detlef Eppig - Vorsitzender des Aufsichtsrats: Francesco de Maio

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2021-01-07 17:35:46 Re: How to keep format of views source code as entered?
Previous Message Tom Lane 2021-01-07 16:47:20 Re: How to keep format of views source code as entered?