SQLSTATE 42804datatype_mismatchHTTP 400
Postgres error 42804: datatype mismatch
column "x" is of type integer but expression is of type text
A datatype mismatch: the value type does not match the target and Postgres will not convert it implicitly.
Common causes
- Inserting a text parameter into a numeric, uuid or jsonb column without a cast.
- CASE branches or UNION columns with different types.
How to fix it
- Cast explicitly ($1::uuid, $2::jsonb).
- Make all branches of CASE or UNION return the same type.
Through a REST API
PostgREST, the REST layer behind supabase-js and Scribase, answers HTTP 400 for this error and returns the SQLSTATE in the code field of the JSON error body.
Questions
What does Postgres error 42804 mean?
42804 is datatype_mismatch in class 42 (Syntax Error or Access Rule Violation). A datatype mismatch: the value type does not match the target and Postgres will not convert it implicitly.
How do I fix 42804?
Cast explicitly ($1::uuid, $2::jsonb). Make all branches of CASE or UNION return the same type.
What HTTP status does a REST API return for 42804?
PostgREST, the REST layer behind supabase-js, answers 400.