From: Alban Hertroys <haramrae@gmail.com>
To: Alex Williams <valenceshell@protonmail.com>
Cc: Markhof, Ingolf <ingolf.markhof@de.verizon.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: How to keep format of views source code as entered?
Date: Tue, 12 Jan 2021 22:17:36 +0100
Message-ID: <2EBD9AAF-9BEC-4489-9B49-9E954695E940@gmail.com> (raw)
In-Reply-To: <ZwqaxBS916weX4SzlaECaBjVVtgHynQCALiE9WcwI1JSPyG12aquNuTzCgxwJZgX1Y6yprQZKejb8Nga-kULrMog4chx0a7zu0nP_OIhaeE=@protonmail.com>
References: <d082c7257ff647e9aba17790938e92de@MS-FRA-E13EX02.intl.ad.vzwcorp.com>
<ZwqaxBS916weX4SzlaECaBjVVtgHynQCALiE9WcwI1JSPyG12aquNuTzCgxwJZgX1Y6yprQZKejb8Nga-kULrMog4chx0a7zu0nP_OIhaeE=@protonmail.com>
> On 12 Jan 2021, at 20:54, Alex Williams <valenceshell@protonmail.com> wrote:
>
> Hi Ingolf,
>
> For comments in views, I create a unused CTE and put my comments there, e.g.
>
> WITH v_comments AS (
> SELECT 'this is my comment' AS comment
> )
>
> Alex
You do know about COMMENT ON VIEW v_comments IS ’this is my comment’, right?
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, January 7, 2021 11:19 AM, Markhof, Ingolf <ingolf.markhof@de.verizon.com> wrote:
>
>> 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
>>
>
Alban Hertroys
--
There is always an exception to always.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: haramrae@gmail.com, valenceshell@protonmail.com, ingolf.markhof@de.verizon.com
Subject: Re: How to keep format of views source code as entered?
In-Reply-To: <2EBD9AAF-9BEC-4489-9B49-9E954695E940@gmail.com>
References: <d082c7257ff647e9aba17790938e92de@MS-FRA-E13EX02.intl.ad.vzwcorp.com> <ZwqaxBS916weX4SzlaECaBjVVtgHynQCALiE9WcwI1JSPyG12aquNuTzCgxwJZgX1Y6yprQZKejb8Nga-kULrMog4chx0a7zu0nP_OIhaeE=@protonmail.com> <2EBD9AAF-9BEC-4489-9B49-9E954695E940@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox