Let's take for instance this table created in postgres:
CREATE TABLE public.item (
id uuid NOT NULL DEFAULT gen_random_uuid(),
"size_type" public."size_type" NULL)
and this data type:
CREATE TYPE public."size_type" AS ENUM (
'small',
'medium',
'large');
What I want to do is to generate with HoneySQL the following SQL query for insert the value 'small' into the "size_type" field of the item table
INSERT INTO item ("size_type") VALUES ('small'::size_type);
I am using this approach:
{:insert-into :item :values [{:size_type "small"}]}
But I am getting this mismatch error:
"message": "Conflict: Uncaught PSQL exception: ERROR: column "size_type" is of type size_type but expression is of type character varying\n Hint: You will need to rewrite or cast the expression.\n Position: 172", "psql-error-type": "DATATYPE_MISMATCH"
As Eugene said in his comment, what you need is
:cast
-- here's a few possible approaches, showing the SQL that would be generated in each case: