Error while executing Postgres node (ERROR: operator does not exist: uuid = text)

Hello everyone!
Faced the following problem in Postgres node.

This query works:

SELECT wt.uuid AS wt_uuid, ct.uuid AS ct_uuid, ct.text AS ct_text, ctm.uuid AS ctm_uuid, ctm.article AS ctm_article
FROM public."work_task" wt
LEFT JOIN public."complete_task_miratext" ctm ON ctm.work_task = '{{$json["uuid"]}}'
LEFT JOIN public."complete_task" ct ON ct.work_task = '{{$json["uuid"]}}'
WHERE wt.uuid = '{{$json["uuid"]}}';

But such a request does not work:

SELECT wt.uuid AS wt_uuid, mftm.uuid AS mftm_uuid, mftm.order AS mftm_order, mfp.name AS mfp_name, ct.uuid AS ct_uuid, ct.text AS ct_text, ctm.uuid AS ctm_uuid, ctm.article AS ctm_article
FROM public."work_task" wt
LEFT JOIN public."complete_task_miratext" ctm ON ctm.work_task = wt.uuid
LEFT JOIN public."complete_task" ct ON ct.work_task = wt.uuid
LEFT JOIN public."meta_field_in_task_master" mftm ON mftm.uuid = wt.meta_field_in_task_master
LEFT JOIN public."meta_field_in_project" mfp ON mfp.uuid = mftm.meta_field_in_project
LEFT JOIN public."meta_field" mf ON mf.uuid = mfp.meta_field
LEFT JOIN public."meta_field_type" mft ON mft.uuid = mf.type
LEFT JOIN public."posting_way" pw ON pw.uuid = mft.posting_way
WHERE wt.uuid = '{{$json["uuid"]}}';

Throws the following error: “ERROR: operator does not exist: uuid = text”

What am I doing wrong?

Hi @Roket, this message comes from PostgreSQL rather than n8n. It seems like PostgreSQL is expecting a uuid datatype for your second query rather than a text. Without knowing the specifics of your databases or the value you are passing on it’ll be hard to tell why that’s happening for only one of your queries.

You could try explicitly casting the field when querying (e.g. ... WHERE wt.uuid::text = '...') as a first step.

1 Like

@MutedJam, Yes, thanks for the answer, you were right! There is one table where the “uuid” column was of type uuid, I changed the type to text and it worked.

1 Like