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.
Seen on:
PostgreSQL
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026