From: Lele Gaifax <lele@metapensiero.it>
To: pgsql-general@postgresql.org
Subject: Difference between CAST(v AS t) and v::t
Date: Sat, 11 Nov 2017 12:29:37 +0100
Message-ID: <87k1yx3vfi.fsf@metapensiero.it> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>
Hi all,
while writing test cases for my SQL pretty printer tool[1], I found what seems
a discrepancy in the "Type Casts" documentation[2]: it states that the two
syntaxes are equivalent, but while
CREATE TABLE contracts (
...
company_id uuid NOT NULL,
validity daterange NOT NULL,
EXCLUDE USING gist (CAST(company_id AS text) WITH =, validity WITH &&)
)
works, the following
CREATE TABLE contracts (
...
company_id uuid NOT NULL,
validity daterange NOT NULL,
EXCLUDE USING gist (company_id::text WITH =, validity WITH &&)
)
is rejected with the message "syntax error at or near "::"".
Am I misreading the documentation, or is it missing some special case?
Thanks in advance for any explanation,
ciao, lele.
[1] https://github.com/lelit/pg_query
[2] https://www.postgresql.org/docs/10/static/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it | -- Fortunato Depero, 1929.
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
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: lele@metapensiero.it
Subject: Re: Difference between CAST(v AS t) and v::t
In-Reply-To: <87k1yx3vfi.fsf@metapensiero.it>
References: <87k1yx3vfi.fsf@metapensiero.it>
* 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