Skip to content

Commit 0cfadb5

Browse files
committed
fix: add uuid to db
1 parent 0d74cdc commit 0cfadb5

File tree

8 files changed

+381
-303
lines changed

8 files changed

+381
-303
lines changed

test/db/00-init.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ CREATE TABLE public.users (
99
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
1010
name text,
1111
status user_status DEFAULT 'ACTIVE',
12-
decimal numeric
12+
decimal numeric,
13+
user_uuid uuid DEFAULT gen_random_uuid()
1314
);
1415
INSERT INTO
1516
public.users (name)

test/lib/functions.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ test('list set-returning function with single object limit', async () => {
7575
"definition": "
7676
SELECT * FROM public.users_audit WHERE user_id = user_row.id;
7777
",
78-
"id": 16506,
78+
"id": 16507,
7979
"identity_argument_types": "user_row users",
8080
"is_set_returning_function": true,
8181
"language": "sql",
8282
"name": "get_user_audit_setof_single_row",
8383
"prorows": 1,
8484
"return_type": "SETOF users_audit",
85-
"return_type_id": 16418,
86-
"return_type_relation_id": 16416,
85+
"return_type_id": 16419,
86+
"return_type_relation_id": 16417,
8787
"schema": "public",
8888
"security_definer": false,
8989
},
@@ -118,15 +118,15 @@ test('list set-returning function with multiples definitions', async () => {
118118
"definition": "
119119
SELECT * FROM public.todos WHERE "user-id" = user_row.id;
120120
",
121-
"id": 16509,
121+
"id": 16510,
122122
"identity_argument_types": "user_row users",
123123
"is_set_returning_function": true,
124124
"language": "sql",
125125
"name": "get_todos_setof_rows",
126126
"prorows": 1000,
127127
"return_type": "SETOF todos",
128-
"return_type_id": 16404,
129-
"return_type_relation_id": 16402,
128+
"return_type_id": 16405,
129+
"return_type_relation_id": 16403,
130130
"schema": "public",
131131
"security_definer": false,
132132
},
@@ -136,7 +136,7 @@ test('list set-returning function with multiples definitions', async () => {
136136
"has_default": false,
137137
"mode": "in",
138138
"name": "todo_row",
139-
"type_id": 16404,
139+
"type_id": 16405,
140140
},
141141
],
142142
"argument_types": "todo_row todos",
@@ -153,15 +153,15 @@ test('list set-returning function with multiples definitions', async () => {
153153
"definition": "
154154
SELECT * FROM public.todos WHERE "user-id" = todo_row."user-id";
155155
",
156-
"id": 16510,
156+
"id": 16511,
157157
"identity_argument_types": "todo_row todos",
158158
"is_set_returning_function": true,
159159
"language": "sql",
160160
"name": "get_todos_setof_rows",
161161
"prorows": 1000,
162162
"return_type": "SETOF todos",
163-
"return_type_id": 16404,
164-
"return_type_relation_id": 16402,
163+
"return_type_id": 16405,
164+
"return_type_relation_id": 16403,
165165
"schema": "public",
166166
"security_definer": false,
167167
},

test/lib/tables.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ test('list', async () => {
3737
id: expect.any(Number),
3838
live_rows_estimate: expect.any(Number),
3939
size: expect.any(String),
40-
},
41-
`
40+
}, `
4241
{
4342
"bytes": Any<Number>,
4443
"columns": [
@@ -117,6 +116,24 @@ test('list', async () => {
117116
"schema": "public",
118117
"table": "users",
119118
},
119+
{
120+
"check": null,
121+
"comment": null,
122+
"data_type": "uuid",
123+
"default_value": "gen_random_uuid()",
124+
"enums": [],
125+
"format": "uuid",
126+
"identity_generation": null,
127+
"is_generated": false,
128+
"is_identity": false,
129+
"is_nullable": true,
130+
"is_unique": false,
131+
"is_updatable": true,
132+
"name": "user_uuid",
133+
"ordinal_position": 5,
134+
"schema": "public",
135+
"table": "users",
136+
},
120137
],
121138
"comment": null,
122139
"dead_rows_estimate": Any<Number>,
@@ -156,8 +173,7 @@ test('list', async () => {
156173
"schema": "public",
157174
"size": Any<String>,
158175
}
159-
`
160-
)
176+
`)
161177
})
162178

163179
test('list without columns', async () => {

test/lib/types.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ test('list types with include Table Types', async () => {
6464
})
6565

6666
expect(res.data?.find(({ name }) => name === 'todos')).toMatchInlineSnapshot(
67-
{ id: expect.any(Number) },
68-
`
67+
{ id: expect.any(Number) }, `
6968
{
7069
"attributes": [],
7170
"comment": null,
@@ -74,10 +73,9 @@ test('list types with include Table Types', async () => {
7473
"id": Any<Number>,
7574
"name": "todos",
7675
"schema": "public",
77-
"type_relation_id": 16402,
76+
"type_relation_id": 16403,
7877
}
79-
`
80-
)
78+
`)
8179
})
8280

8381
test('list types without Table Types', async () => {

test/lib/views.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { pgMeta } from './utils'
44
test('list', async () => {
55
const res = await pgMeta.views.list()
66
expect(res.data?.find(({ name }) => name === 'todos_view')).toMatchInlineSnapshot(
7-
{ id: expect.any(Number) },
8-
`
7+
{ id: expect.any(Number) }, `
98
{
109
"columns": [
1110
{
@@ -15,7 +14,7 @@ test('list', async () => {
1514
"default_value": null,
1615
"enums": [],
1716
"format": "int8",
18-
"id": "16423.1",
17+
"id": "16424.1",
1918
"identity_generation": null,
2019
"is_generated": false,
2120
"is_identity": false,
@@ -26,7 +25,7 @@ test('list', async () => {
2625
"ordinal_position": 1,
2726
"schema": "public",
2827
"table": "todos_view",
29-
"table_id": 16423,
28+
"table_id": 16424,
3029
},
3130
{
3231
"check": null,
@@ -35,7 +34,7 @@ test('list', async () => {
3534
"default_value": null,
3635
"enums": [],
3736
"format": "text",
38-
"id": "16423.2",
37+
"id": "16424.2",
3938
"identity_generation": null,
4039
"is_generated": false,
4140
"is_identity": false,
@@ -46,7 +45,7 @@ test('list', async () => {
4645
"ordinal_position": 2,
4746
"schema": "public",
4847
"table": "todos_view",
49-
"table_id": 16423,
48+
"table_id": 16424,
5049
},
5150
{
5251
"check": null,
@@ -55,7 +54,7 @@ test('list', async () => {
5554
"default_value": null,
5655
"enums": [],
5756
"format": "int8",
58-
"id": "16423.3",
57+
"id": "16424.3",
5958
"identity_generation": null,
6059
"is_generated": false,
6160
"is_identity": false,
@@ -66,7 +65,7 @@ test('list', async () => {
6665
"ordinal_position": 3,
6766
"schema": "public",
6867
"table": "todos_view",
69-
"table_id": 16423,
68+
"table_id": 16424,
7069
},
7170
],
7271
"comment": null,
@@ -75,8 +74,7 @@ test('list', async () => {
7574
"name": "todos_view",
7675
"schema": "public",
7776
}
78-
`
79-
)
77+
`)
8078
})
8179

8280
test('list without columns', async () => {
@@ -100,8 +98,7 @@ test('list without columns', async () => {
10098
test('retrieve', async () => {
10199
const res = await pgMeta.views.retrieve({ schema: 'public', name: 'todos_view' })
102100
expect(res).toMatchInlineSnapshot(
103-
{ data: { id: expect.any(Number) } },
104-
`
101+
{ data: { id: expect.any(Number) } }, `
105102
{
106103
"data": {
107104
"columns": [
@@ -112,7 +109,7 @@ test('retrieve', async () => {
112109
"default_value": null,
113110
"enums": [],
114111
"format": "int8",
115-
"id": "16423.1",
112+
"id": "16424.1",
116113
"identity_generation": null,
117114
"is_generated": false,
118115
"is_identity": false,
@@ -123,7 +120,7 @@ test('retrieve', async () => {
123120
"ordinal_position": 1,
124121
"schema": "public",
125122
"table": "todos_view",
126-
"table_id": 16423,
123+
"table_id": 16424,
127124
},
128125
{
129126
"check": null,
@@ -132,7 +129,7 @@ test('retrieve', async () => {
132129
"default_value": null,
133130
"enums": [],
134131
"format": "text",
135-
"id": "16423.2",
132+
"id": "16424.2",
136133
"identity_generation": null,
137134
"is_generated": false,
138135
"is_identity": false,
@@ -143,7 +140,7 @@ test('retrieve', async () => {
143140
"ordinal_position": 2,
144141
"schema": "public",
145142
"table": "todos_view",
146-
"table_id": 16423,
143+
"table_id": 16424,
147144
},
148145
{
149146
"check": null,
@@ -152,7 +149,7 @@ test('retrieve', async () => {
152149
"default_value": null,
153150
"enums": [],
154151
"format": "int8",
155-
"id": "16423.3",
152+
"id": "16424.3",
156153
"identity_generation": null,
157154
"is_generated": false,
158155
"is_identity": false,
@@ -163,7 +160,7 @@ test('retrieve', async () => {
163160
"ordinal_position": 3,
164161
"schema": "public",
165162
"table": "todos_view",
166-
"table_id": 16423,
163+
"table_id": 16424,
167164
},
168165
],
169166
"comment": null,
@@ -174,6 +171,5 @@ test('retrieve', async () => {
174171
},
175172
"error": null,
176173
}
177-
`
178-
)
174+
`)
179175
})

test/server/indexes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test('list indexes', async () => {
2222
0,
2323
],
2424
"comment": null,
25-
"id": 16399,
25+
"id": 16400,
2626
"index_attributes": [
2727
{
2828
"attribute_name": "id",
@@ -57,7 +57,7 @@ test('list indexes', async () => {
5757
})
5858

5959
test('retrieve index', async () => {
60-
const res = await app.inject({ method: 'GET', path: '/indexes/16399' })
60+
const res = await app.inject({ method: 'GET', path: '/indexes/16400' })
6161
const index = res.json<PostgresIndex>()
6262
expect(index).toMatchInlineSnapshot(
6363
`
@@ -71,7 +71,7 @@ test('retrieve index', async () => {
7171
0,
7272
],
7373
"comment": null,
74-
"id": 16399,
74+
"id": 16400,
7575
"index_attributes": [
7676
{
7777
"attribute_name": "id",

test/server/query.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ test('query', async () => {
1414
"id": 1,
1515
"name": "Joe Bloggs",
1616
"status": "ACTIVE",
17+
"user_uuid": "0db4bf5e-98df-4ecf-aa2c-a077323c53b1",
1718
},
1819
{
1920
"decimal": null,
2021
"id": 2,
2122
"name": "Jane Doe",
2223
"status": "ACTIVE",
24+
"user_uuid": "eda00f72-451f-419e-8ede-b7873ad6890c",
2325
},
2426
]
2527
`)
@@ -765,6 +767,7 @@ test('parameter binding with positional parameters', async () => {
765767
"id": 1,
766768
"name": "Joe Bloggs",
767769
"status": "ACTIVE",
770+
"user_uuid": "0db4bf5e-98df-4ecf-aa2c-a077323c53b1",
768771
},
769772
]
770773
`)

0 commit comments

Comments
 (0)