From: | Alex Williams <valenceshell(at)protonmail(dot)com> |
---|---|
To: | Alban Hertroys <haramrae(at)gmail(dot)com> |
Cc: | "Markhof, Ingolf" <ingolf(dot)markhof(at)de(dot)verizon(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: How to keep format of views source code as entered? |
Date: | 2021-01-13 01:01:19 |
Message-ID: | y5vxZU9iQ6Rhot2JzdcKl7TqqAIxpdDRHXNVsqXNmU7G_PrrZCZudjWmFzRK3ew5M9D623xvDbtkYmyzD0fOOm-WqO_-AKC8JENlzdv-E08=@protonmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ugh, I wasn't and just tried it, thanks.
I've saved comments before on pgadmin and wasn't aware it using a sql statement to save it, I thought it was local to my environment.
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, January 12, 2021 4:17 PM, Alban Hertroys <haramrae(at)gmail(dot)com> wrote:
> > On 12 Jan 2021, at 20:54, Alex Williams valenceshell(at)protonmail(dot)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(dot)markhof(at)de(dot)verizon(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | W.P. | 2021-01-13 06:41:59 | System (and DB) upgrade problem. |
Previous Message | Tom Lane | 2021-01-12 23:24:53 | Re: Views and triggers more then one row returned by subquery. |