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

Table Editor Import Sequence Raise Fails For Uppercase Schema/Table/Column Names

The pg-meta identity sequence update SQL builds pg_get_serial_sequence args without quoting identifiers; Postgres case-folds unquoted names causing relation error and skipping sequence raise, leading to duplicate primary key collisions on next inserts.

highConfidence 92%Supabase Studio

Origin Analysis

getUpdateIdentitySequenceSQL uses string interpolation `'${schema}.${table}'` and `'${column}'` inside pg_get_serial_sequence() without applying identifier quoting. Postgres treats these literals as unquoted, case-folding them to lowercase, so uppercase schema/table/column names cause relation/column not found. The sequence is not advanced because setval errors out, leaving it at start value and leading to duplicate key errors on subsequent inserts.
1. Create schema "App"; table "App"."Users" ("Id" bigint generated by default as identity primary key, val text); 2. Insert rows with Id=5,6; 3. In Studio table editor import rows, or manually run `select pg_get_serial_sequence('App.Users', 'Id');`; 4. Observe error relation "app.users" does not exist; 5. Attempt insert into table using identity default, observe duplicate key after sequence not raised.

Fixing Code Block

Edge Case Audit

Ensure ident() is imported from the pg-meta utils; otherwise add the import. The change affects only the sequence raising statement after imports. Rollback: revert to the previous literal interpolation if regressions occur. Testing should cover quoted/escaped identifiers, tables with dots, and concurrent imports to avoid sequence races. This fix does not alter setval is_called semantics; the default true sets next nextval to max + 1.

Ecosystem Topology