Skip to content

Instantly share code, notes, and snippets.

@Komzpa
Created December 14, 2016 20:59
Show Gist options
  • Save Komzpa/f5350a5ef34570447eb01d08e9055768 to your computer and use it in GitHub Desktop.
Save Komzpa/f5350a5ef34570447eb01d08e9055768 to your computer and use it in GitHub Desktop.
gis=> drop type if exists apple;
DROP TYPE
gis=> create type apple as (amount numeric(1,0));
CREATE TYPE
gis=> select '(1)'::apple;
apple
-------
(1)
(1 row)
gis=> select '(1)'::apple = 1;
ERROR: operator does not exist: apple = integer
LINE 1: select '(1)'::apple = 1;
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
gis=> select ('(1)'::apple).amount;
amount
--------
1
(1 row)
gis=> select '(1.55)'::apple;
apple
-------
(2)
(1 row)
gis=> create type apple as (amount bigint);
ERROR: type "apple" already exists
gis=> drop type if exists apple;
DROP TYPE
gis=> create type apple as (amount bigint);
CREATE TYPE
gis=> select '(1)'::apple;
apple
-------
(1)
(1 row)
gis=> select ('(1)'::apple).amount;
amount
--------
1
(1 row)
gis=> select '(1)'::apple = 1;
ERROR: operator does not exist: apple = integer
LINE 1: select '(1)'::apple = 1;
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
gis=> create type cat as (amount bigint);
CREATE TYPE
gis=> select '(1)'::cat = '(1)'::cat;
?column?
----------
t
(1 row)
gis=> select '(1)'::apple = '(1)'::cat;
?column?
----------
t
(1 row)
gis=> select '1' = 1;
?column?
----------
t
(1 row)
gis=> select '1' = 1::float;
?column?
----------
t
(1 row)
gis=> select '1'::text = 1::float;
ERROR: operator does not exist: text = double precision
LINE 1: select '1'::text = 1::float;
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment