Do not put columns in parentheses.
If you look at the full error message you get, Postgres actually tells you what is wrong.
ERROR: INSERT has more target columns than expressions. Tip: The insertion source is a row expression containing the same number of columns expected by INSERT. Have you accidentally used extra parentheses?
The expression ('Wow', 'wow') is just one column, an anonymous βrecordβ with two variables (see the manual for details)
INSERT INTO tags (name, slug) SELECT 'Wow', 'wow' WHERE NOT EXISTS (SELECT id FROM tags WHERE slug = 'wow') RETURNING id;
In general, adding parentheses is only recommended if they are really needed.
a_horse_with_no_name
source share