Column update DROP CONSTRAINT fails for hyphenated check names

Open Beginner friendly
#1,140 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, typescript
Domain
api, databases

Research direction

Start at the postgres-meta columns.update path used by PATCH /columns and compare check-constraint removal with the existing unique-constraint drop logic that uses quote_ident. Reproduce with the provided hyphenated constraint name, then verify that clearing the check succeeds and the constraint is removed without a PostgreSQL syntax error.

Written by the indexing model from the issue text.

Description

Bug

Updating a column via postgres-meta (PATCH /columns / columns.update) to clear or replace a check constraint fails when the existing check constraint name is not a plain unquoted identifier (e.g. hyphenated names like "t-c-check").

The generated SQL uses DROP CONSTRAINT %s, which interpolates the name without quoting. PostgreSQL then treats the hyphen as an operator and raises a syntax error. Unique-constraint drops in the same code path already use quote_ident; check drops should use identifier quoting (%I) as well.

Repro

create table public.t (c int8);
alter table public.t add constraint "t-c-check" check (c <> 0);

Then clear the check through postgres-meta:

const col = await pgMeta.columns.retrieve({ schema: 'public', table: 't', name: 'c' })
await pgMeta.columns.update(col.data!.id, { check: null })

Expected: check removed (check: null).

Actual: SQL error near - from DROP CONSTRAINT t-c-check (unquoted).

Impact

Studio / Management API column edits that clear or change checks break for any table whose check constraint was named with quotes, hyphens, mixed case, etc. (common when tools or users pick explicit constraint names).

Dominant language
TypeScript
Stars
1.2k
Forks
223
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/postgres-meta

All issues in supabase/postgres-meta

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.