AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Table Editor Drops And Re-Adds Primary Key On Saves That Don'T Change It

The Table Editor's updateTable function incorrectly compares primary key column names in display order against the primary_keys array (which is in key order). This false mismatch causes the primary key constraint to be dropped and re-added, leading to save failures when foreign keys reference the primary key, or silent reordering of composite primary keys.

highConfidence 85%Supabase StudioPostgreSQLEdge Functions

Origin Analysis

The comparison logic uses column display order instead of column identity. When display order differs from the key's internal order (as in composite keys like (b,a) or after renames), the code sees a difference and attempts to rebuild the primary key. This is a design flaw in handling primary key comparison.
1. Open Supabase Studio Table Editor for a table with a composite primary key (e.g., (b, a)). 2. Modify an unrelated column property (e.g., description) or rename a column. 3. Save the changes. 4. Observe that the primary key is dropped and re-added, causing an error if foreign keys reference it, or silently changing the key order to (a, b).

Fixing Code Block

Edge Case Audit

This fix assumes column IDs are unique and stable. If the table editor ever changes column IDs (unlikely but possible during certain operations), the comparison could miss legitimate primary key changes. Additionally, if the primary key involves columns that are deleted and recreated with new IDs, the fix might not detect the change. To rollback safely, revert to the previous name-based comparison but ensure the comparison uses the primary key order as returned by the database, not display order. Test thoroughly with composite keys and foreign key dependencies.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state