Skip to content

Commit 1b3fbef

Browse files
committed
test(lib/columns): update is_unique
1 parent c861051 commit 1b3fbef

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

test/lib/columns.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,64 @@ Object {
408408

409409
await pgMeta.tables.remove(testTable!.id)
410410
})
411+
412+
test('update is_unique', async () => {
413+
const { data: testTable } = await pgMeta.tables.create({ name: 't' })
414+
415+
let res = await pgMeta.columns.create({
416+
table_id: testTable!.id,
417+
name: 'c',
418+
type: 'text',
419+
is_unique: false,
420+
})
421+
res = await pgMeta.columns.update(res.data!.id, { is_unique: true })
422+
expect(res).toMatchInlineSnapshot(`
423+
Object {
424+
"data": Object {
425+
"comment": null,
426+
"data_type": "text",
427+
"default_value": null,
428+
"enums": Array [],
429+
"format": "text",
430+
"id": "16525.1",
431+
"identity_generation": null,
432+
"is_identity": false,
433+
"is_nullable": true,
434+
"is_unique": true,
435+
"is_updatable": true,
436+
"name": "c",
437+
"ordinal_position": 1,
438+
"schema": "public",
439+
"table": "t",
440+
"table_id": 16525,
441+
},
442+
"error": null,
443+
}
444+
`)
445+
res = await pgMeta.columns.update(res.data!.id, { is_unique: false })
446+
expect(res).toMatchInlineSnapshot(`
447+
Object {
448+
"data": Object {
449+
"comment": null,
450+
"data_type": "text",
451+
"default_value": null,
452+
"enums": Array [],
453+
"format": "text",
454+
"id": "16525.1",
455+
"identity_generation": null,
456+
"is_identity": false,
457+
"is_nullable": true,
458+
"is_unique": false,
459+
"is_updatable": true,
460+
"name": "c",
461+
"ordinal_position": 1,
462+
"schema": "public",
463+
"table": "t",
464+
"table_id": 16525,
465+
},
466+
"error": null,
467+
}
468+
`)
469+
470+
await pgMeta.tables.remove(testTable!.id)
471+
})

0 commit comments

Comments
 (0)