Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/PostgresMetaColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ BEGIN
IF v_conname IS NOT NULL THEN
EXECUTE format('ALTER TABLE ${ident(old!.schema)}.${ident(
old!.table
)} DROP CONSTRAINT %s', v_conname);
)} DROP CONSTRAINT %I', v_conname);
END IF;

${
Expand Down
21 changes: 21 additions & 0 deletions test/lib/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,27 @@ test('dropping column checks', async () => {
await pgMeta.query(`drop table t`)
})

test('dropping hyphenated column check constraints', async () => {
await pgMeta.query(`
create table public.t (c int8);
alter table public.t add constraint "t-c-check" check (c <> 0);
`)

let res = await pgMeta.columns.retrieve({
schema: 'public',
table: 't',
name: 'c',
})
expect(res.error).toBeNull()
expect(res.data?.check).toBeTruthy()

res = await pgMeta.columns.update(res.data!.id, { check: null })
expect(res.error).toBeNull()
expect(res.data?.check).toBeNull()

await pgMeta.query(`drop table public.t`)
})

test('column with fully-qualified type', async () => {
await pgMeta.query(`create table public.t(); create schema s; create type s.my_type as enum ();`)

Expand Down