Skip to content

Column update DROP CONSTRAINT fails for hyphenated check names #1140

Description

@hsusul

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions