ERROR: column "x" is of type integer but expression is of type text — HINT: You will need to rewrite or cast the expression.
An INSERT/UPDATE supplies a value of a different type than the column, and PostgreSQL won’t cast implicitly.
but expression is of type Meaning
Parameters bound as text, jsonb vs json, or enum columns receiving text. Explicit casts fix it.
Common causes
- Parameters sent as strings
- Enum column receiving text without cast
- json vs jsonb mismatch
⚡ Quick fix
- Cast: $1::int / $1::my_enum
- Fix the driver/ORM type mapping
Detailed fix by platform
PostgreSQL
UPDATE orders SET status = $1::order_status WHERE id = $2;
How to diagnose
- Types — Column type vs expression type
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 08P01 ERROR: bind message supplies 2 parameters, but prepared statement requires 1
- 1093 MySQL ERROR 1093 (HY000): You can't specify target table 'x' for update in FROM clause
- 1175 MySQL ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
Most viewed in PostgreSQL
- could not connect PostgreSQL: could not connect to server / connection refused — Is the server running on host and accepting TCP/IP connections?
- pg_restore text dump pg_restore: error: input file appears to be a text format dump. Please use psql.
- 25P02 ERROR: current transaction is aborted, commands ignored until end of transaction block
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026