Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kzR3U-0000Fc-B3 for pgsql-general@arkaria.postgresql.org; Tue, 12 Jan 2021 21:18:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kzR2w-0006xe-8G for pgsql-general@arkaria.postgresql.org; Tue, 12 Jan 2021 21:17:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kzR2v-0006xW-TG for pgsql-general@lists.postgresql.org; Tue, 12 Jan 2021 21:17:46 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kzR2p-0007Tg-GN for pgsql-general@lists.postgresql.org; Tue, 12 Jan 2021 21:17:45 +0000 Received: by mail-ed1-x535.google.com with SMTP id dk8so3988209edb.1 for ; Tue, 12 Jan 2021 13:17:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=C5STpECDobB/5mz0tJpPLKV4ADsomhiRESRPJTA3gME=; b=DRE1ePFAkGdyPUrtljg2EWeYjXzS8dSLXtQbLiuG+Y8iHReCg3+IvuCKiFIGpnyBhD u09gpJWQrDKNoJGj7znLQnqu3t44Jva+fGSlHedJ9oh2djdUykOEOHGJoghRR4b7EmRd LnwhPOcrfMWP4rK2GQZTNkrElhJqNkiurG7Zo/hlprFdtpLAhV4cCVjC+0pQ0azHIxQV pyELKUIDI1X944q7Ti4KclTQa1Jairns0I4JmnrMHRE4zAZV+OOv9ACTLceEo9K4sby0 2+hMypzL3JnXGEiAzIkfMg+FSjGyu83WJy0s8OtfnyasAWRrk/6oOCypqH0pFUvxoJUw tQow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=C5STpECDobB/5mz0tJpPLKV4ADsomhiRESRPJTA3gME=; b=M9e4+Ar+QZqlKb4OSB2P+YYFk2zaB8WLI77O3xtpSd7QoKWGRJAbdxYwlFv+BUgIpS lxLqtuXZbd/N64fne8lOszrATr4dSz8O+x9WQfEkXCCksDz96C4ATRmzYiRrx0INVKA4 2lStm2f+nSt4gTMRQcE3LWush50eTOLHjI9zhh5ymB+N66ZN84N/jqoidfx/n9pLwXRL fUfWd3eTS06VepxwlpdRBhxQq7VDImAKZKeYJuugR1yTMXZKO+a2lfLyiKMtkQ0Om0Yp yhJEZEuL4Lot5I6ANlSOsA/Mnmaoq8qwOH8SZdYJtPQth1H6AqHfN5Gw5z85APMQUT8r dPwg== X-Gm-Message-State: AOAM530uAqYN5+iyO6UA7+obTFYMwYEUF4XTme5On2d0sxHIkfdy++cV QSMwbtB/e28d6IvRp1PE1ck= X-Google-Smtp-Source: ABdhPJyFGJ85nqBW+7zq60aJzKC5NzbNRDzyEg0DIBbsAZiKsaQX9XHk3DGhwmxRiAN21Dm1ekQsFg== X-Received: by 2002:a05:6402:168f:: with SMTP id a15mr907143edv.376.1610486257770; Tue, 12 Jan 2021 13:17:37 -0800 (PST) Received: from hollewijn.internal (217-19-30-105.dsl.cambrium.nl. [217.19.30.105]) by smtp.gmail.com with ESMTPSA id v18sm1653976ejw.18.2021.01.12.13.17.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jan 2021 13:17:37 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Subject: Re: How to keep format of views source code as entered? From: Alban Hertroys In-Reply-To: Date: Tue, 12 Jan 2021 22:17:36 +0100 Cc: "Markhof, Ingolf" , "pgsql-general@lists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <2EBD9AAF-9BEC-4489-9B49-9E954695E940@gmail.com> References: To: Alex Williams X-Mailer: Apple Mail (2.3445.104.17) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On 12 Jan 2021, at 20:54, Alex Williams = wrote: >=20 > Hi Ingolf, >=20 > For comments in views, I create a unused CTE and put my comments = there, e.g. >=20 > WITH v_comments AS ( > SELECT 'this is my comment' AS comment > ) >=20 > Alex You do know about COMMENT ON VIEW v_comments IS =E2=80=99this is my = comment=E2=80=99, right? > =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 = Original Message =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2= =80=90 > On Thursday, January 7, 2021 11:19 AM, Markhof, Ingolf = wrote: >=20 >> Hi! >>=20 >> =20 >>=20 >> 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). >>=20 >> =20 >>=20 >> 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? >>=20 >> =20 >>=20 >> Any hints welcome! >>=20 >> =20 >>=20 >> Here is an example: >>=20 >> =20 >>=20 >> I enter this code to define a simple view: >>=20 >> =20 >>=20 >> create or replace view myview as >>=20 >> select >>=20 >> product_id, >>=20 >> product_acronym >>=20 >> from >>=20 >> products -- my comment here >>=20 >> where >>=20 >> product_acronym =3D 'ABC' >>=20 >> ; >>=20 >> =20 >>=20 >> However, when I open the view my SQL client (DBeaver) again, this is = what I get: >>=20 >> =20 >>=20 >> CREATE OR REPLACE VIEW myview >>=20 >> AS SELECT product_id, >>=20 >> product_acronym >>=20 >> FROM products >>=20 >> WHERE product_acronym =3D 'ABC'::text; >>=20 >> =20 >>=20 >> 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. >>=20 >> =20 >>=20 >> =20 >>=20 >> =20 >>=20 >> =20 >>=20 >>=20 >> Verizon Deutschland GmbH - Sebrathweg 20, 44149 Dortmund, Germany - = Amtsgericht Dortmund, HRB 14952 - Gesch=C3=A4ftsf=C3=BChrer: Detlef = Eppig - Vorsitzender des Aufsichtsrats: Francesco de Maio >>=20 >=20 Alban Hertroys -- There is always an exception to always.