Search Postgresql Archives

Difference between CAST(v AS t) and v::t

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx  |                 -- Fortunato Depero, 1929.



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux