PostgREST error: 400 'column example_table.example_column does not exist' when using OR operators
If you receive a 400 error with the message column example_table.example_column does not exist only on mutation requests (PATCH, POST, DELETE) — while SELECT queries on the same column work fine — this is a known bug in PostgREST versions prior to 14.4 (issue #3707).
Root cause
The bug is triggered when an or() filter is included in a mutation request. PostgREST incorrectly applies the OR filter’s column resolution logic to the mutation plan, causing it to fail to locate columns that exist and are otherwise accessible.
How to confirm
- Reproduce the asymmetry — run the same filter as a
GETrequest. If it succeeds but thePATCH/POST/DELETEfails with the same column reference, the bug is the likely cause. - Check your PostgREST version — go to Project Settings > Infrastructure and note the PostgreSQL version. PostgREST 14.1 and earlier are affected; 14.4+ includes the fix.
- Check Postgres logs — if you have logging enabled, you should see
column "example_column" does not existerrors correlating with the timestamps of the failed mutation requests.
Resolution
Option 1: Upgrade (permanent fix)
Navigate to Project Settings > Infrastructure and upgrade to the latest PostgreSQL version. This automatically upgrades PostgREST to 14.5+, where the bug is resolved.
Option 2: Query workaround (immediate)
Explicitly include the column referenced in the error in the select parameter of your mutation request. This forces PostgREST to resolve the column correctly during the mutation plan.
For example, if your request looks like:
PATCH /rest/v1/example_table?or=(example_column.eq.value1,example_column.eq.value2)Add select= with the affected column:
PATCH /rest/v1/example_table?or=(example_column.eq.value1,example_column.eq.value2)&select=id,example_columnThis workaround applies per-request and does not require any schema changes or infrastructure modifications.
Related topics
- PostgREST error codes
- Handling errors in supabase-js
- REST API overview
- Discovering and interpreting API errors in the logs