postgresql-simple icon indicating copy to clipboard operation
postgresql-simple copied to clipboard

UUID ToField instance doesn't work when type can't be inferred from context

Open kmicklas opened this issue 4 years ago • 0 comments

The following query works:

select uuid_generate_v3(t.x, 'foo') from (values ('55c163fc-8e21-4f2a-b26d-6a7fa3e5d896'::uuid)) as t(x);

but this does not:

select uuid_generate_v3(t.x, 'foo') from (values ('55c163fc-8e21-4f2a-b26d-6a7fa3e5d896')) as t(x);

The ToField instance for UUID only outputs the quoted text, so it will fail when interpolated into a query like the second one. I guess if you're using postgresql-simple directly you can just know to append ::uuid in the query text, but this is a problem for higher level query libraries like Beam which would like to reuse postgresql-simple's ToField instances and generate query strings parametrically.

kmicklas avatar Mar 14 '21 16:03 kmicklas