Skip to content

Commit f418160

Browse files
committed
fix: updating column check
1 parent 596e81f commit f418160

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/lib/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ export const postgresColumnUpdateSchema = Type.Object({
7777
is_nullable: Type.Optional(Type.Boolean()),
7878
is_unique: Type.Optional(Type.Boolean()),
7979
comment: Type.Optional(Type.String()),
80-
check: Type.Optional(Type.Union([Type.String(), Type.Null()])),
80+
check: Type.Optional(
81+
Type.Union(
82+
// Type.Null() must go first: https://github.com/sinclairzx81/typebox/issues/546
83+
[Type.Null(), Type.String()]
84+
)
85+
),
8186
})
8287
export type PostgresColumnUpdate = Static<typeof postgresColumnUpdateSchema>
8388

test/lib/columns.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,3 +933,17 @@ test('column with multiple checks', async () => {
933933

934934
await pgMeta.query(`drop table t`)
935935
})
936+
937+
test('dropping column checks', async () => {
938+
await pgMeta.query(`create table public.t(c int8 check (c != 0))`)
939+
940+
let res = await pgMeta.columns.retrieve({
941+
schema: 'public',
942+
table: 't',
943+
name: 'c',
944+
})
945+
res = await pgMeta.columns.update(res.data!.id, { check: null })
946+
expect(res?.data?.check).toMatchInlineSnapshot(`null`)
947+
948+
await pgMeta.query(`drop table t`)
949+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy