name: supabase-broker-links-display-order-fix
description: Fix 400 Bad Request on broker_links REST queries when order=display_order.asc column is missing
Supabase broker_links 400 on order=display_order.asc
Symptoms
- -
GET /rest/v1/broker_links?select=*&order=display_order.ascreturns400 Bad Request - - Admin panel and "รrea do Corretor" page both fail with console errors
- - PostgREST rejects the query before checking RLS
Root Cause
The broker_links table is missing the display_order column. PostgREST validates column existence before processing the query.
Fix
`sql
ALTER TABLE broker_links ADD COLUMN display_order INTEGER NOT NULL DEFAULT 0;
`
If the column exists but the error persists, check for:
1. RLS policies blocking access (RLS errors usually return 400 with specific message)
2. Column type mismatch (e.g., order=display_order.asc requires integer or sortable type)
3. Verify with: SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'broker_links';
Verification
`bash
Test without auth (anon key)
curl -s "https://rochasalesseguros.com.br/rest/v1/broker_links?select=id,title,display_order&order=display_order.asc" \
-H "apikey:
Should return: [{"id":"...","title":"...","display_order":0},...]
`
Key Debugging Insight
When PostgREST returns 400 on an order= clause, the column does not exist in the table. This happens before RLS is checked. Always verify the schema first:
`sql
SELECT column_name, data_type FROM information_schema.columns
WHERE table_name = 'broker_links' ORDER BY ordinal_position;
`