On 05/31/2018 06:39 AM, Tom Lane wrote:
Adrian Klaver <adrian.klaver@xxxxxxxxxxx> writes:
My suspicion is it had to do with this from a post upstream:
"When I tried it, I am getting an error: Invalid input syntax for UUID:
uuid_generate_v4(),"
Yeah. We haven't seen the actual query yet, but I'm betting the OP
really wrote
INSERT ... , 'uuid_generate_v4()', ...
not
INSERT ... , uuid_generate_v4(), ...
There might be some layers of client-side parameter mangling obscuring
what's actually happening.
I would tend to agree:
\d uuid_test
Table "public.uuid_test"
Column | Type | Collation | Nullable | Default
----------+------+-----------+----------+---------
uuid_fld | uuid |
insert into uuid_test values (uuid_generate_v4());
INSERT 0 1
select * from uuid_test ;
uuid_fld
--------------------------------------
f4bc853b-0c05-437b-904a-825cc6d3ea7b
In Python(using psycopg2) which is what the OP is using;
cur.execute("INSERT INTO uuid_test values(uuid_generate_v4())")
con.commit()
cur.execute("SELECT uuid_fld FROM uuid_test")
rs = cur.fetchall()
rs
[('f4bc853b-0c05-437b-904a-825cc6d3ea7b',),
('9e55f5ea-c504-4847-8674-05202ec499c6',)]
From this post:
https://www.postgresql.org/message-id/CAA6wQLLVpjtxAhPy3K1f63WtvqjK4QrzBLKjeh0PDUOyCvbT2Q%40mail.gmail.com
the OP seems to be on the right track. So something else is happening.
regards, tom lane
--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx