Skip to content

Commit 0262ebc

Browse files
committed
fix: include materializedView types
1 parent f8321c6 commit 0262ebc

File tree

4 files changed

+86
-3
lines changed

4 files changed

+86
-3
lines changed

src/lib/sql/types.sql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ from
4747
t.typrelid = 0
4848
or (
4949
select
50-
c.relkind ${props.includeTableTypes ? `in ('c', 'r', 'v')` : `= 'c'`}
50+
c.relkind ${props.includeTableTypes ? `in ('c', 'r', 'v', 'm')` : `= 'c'`}
5151
from
5252
pg_class c
5353
where

test/db/00-init.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ AS $$
203203
SELECT * FROM public.users_audit WHERE user_id = user_row.id;
204204
$$;
205205

206+
CREATE OR REPLACE FUNCTION public.get_todos_by_matview(todos_matview)
207+
RETURNS SETOF todos ROWS 1
208+
LANGUAGE SQL STABLE
209+
AS $$
210+
SELECT * FROM public.todos LIMIT 1;
211+
$$;
212+
206213
CREATE OR REPLACE FUNCTION public.get_todos_setof_rows(user_row users)
207214
RETURNS SETOF todos
208215
LANGUAGE SQL STABLE

test/lib/functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ 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": 16507,
121+
"id": 16508,
122122
"identity_argument_types": "user_row users",
123123
"is_set_returning_function": true,
124124
"language": "sql",
@@ -153,7 +153,7 @@ 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": 16508,
156+
"id": 16509,
157157
"identity_argument_types": "todo_row todos",
158158
"is_set_returning_function": true,
159159
"language": "sql",

test/server/typegen.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ test('typegen: typescript', async () => {
306306
details: string | null
307307
id: number | null
308308
"user-id": number | null
309+
get_todos_by_matview: {
310+
details: string | null
311+
id: number
312+
"user-id": number
313+
} | null
309314
}
310315
Relationships: [
311316
{
@@ -628,6 +633,20 @@ test('typegen: typescript', async () => {
628633
user_status: Database["public"]["Enums"]["user_status"] | null
629634
}
630635
}
636+
get_todos_by_matview: {
637+
Args: { "": unknown }
638+
Returns: {
639+
details: string | null
640+
id: number
641+
"user-id": number
642+
}
643+
SetofOptions: {
644+
from: "todos_matview"
645+
to: "todos"
646+
isOneToOne: true
647+
isSetofReturn: true
648+
}
649+
}
631650
get_todos_from_user:
632651
| {
633652
Args: {
@@ -1347,6 +1366,11 @@ test('typegen w/ one-to-one relationships', async () => {
13471366
details: string | null
13481367
id: number | null
13491368
"user-id": number | null
1369+
get_todos_by_matview: {
1370+
details: string | null
1371+
id: number
1372+
"user-id": number
1373+
} | null
13501374
}
13511375
Relationships: [
13521376
{
@@ -1681,6 +1705,20 @@ test('typegen w/ one-to-one relationships', async () => {
16811705
user_status: Database["public"]["Enums"]["user_status"] | null
16821706
}
16831707
}
1708+
get_todos_by_matview: {
1709+
Args: { "": unknown }
1710+
Returns: {
1711+
details: string | null
1712+
id: number
1713+
"user-id": number
1714+
}
1715+
SetofOptions: {
1716+
from: "todos_matview"
1717+
to: "todos"
1718+
isOneToOne: true
1719+
isSetofReturn: true
1720+
}
1721+
}
16841722
get_todos_from_user:
16851723
| {
16861724
Args: {
@@ -2400,6 +2438,11 @@ test('typegen: typescript w/ one-to-one relationships', async () => {
24002438
details: string | null
24012439
id: number | null
24022440
"user-id": number | null
2441+
get_todos_by_matview: {
2442+
details: string | null
2443+
id: number
2444+
"user-id": number
2445+
} | null
24032446
}
24042447
Relationships: [
24052448
{
@@ -2734,6 +2777,20 @@ test('typegen: typescript w/ one-to-one relationships', async () => {
27342777
user_status: Database["public"]["Enums"]["user_status"] | null
27352778
}
27362779
}
2780+
get_todos_by_matview: {
2781+
Args: { "": unknown }
2782+
Returns: {
2783+
details: string | null
2784+
id: number
2785+
"user-id": number
2786+
}
2787+
SetofOptions: {
2788+
from: "todos_matview"
2789+
to: "todos"
2790+
isOneToOne: true
2791+
isSetofReturn: true
2792+
}
2793+
}
27372794
get_todos_from_user:
27382795
| {
27392796
Args: {
@@ -3458,6 +3515,11 @@ test('typegen: typescript w/ postgrestVersion', async () => {
34583515
details: string | null
34593516
id: number | null
34603517
"user-id": number | null
3518+
get_todos_by_matview: {
3519+
details: string | null
3520+
id: number
3521+
"user-id": number
3522+
} | null
34613523
}
34623524
Relationships: [
34633525
{
@@ -3792,6 +3854,20 @@ test('typegen: typescript w/ postgrestVersion', async () => {
37923854
user_status: Database["public"]["Enums"]["user_status"] | null
37933855
}
37943856
}
3857+
get_todos_by_matview: {
3858+
Args: { "": unknown }
3859+
Returns: {
3860+
details: string | null
3861+
id: number
3862+
"user-id": number
3863+
}
3864+
SetofOptions: {
3865+
from: "todos_matview"
3866+
to: "todos"
3867+
isOneToOne: true
3868+
isSetofReturn: true
3869+
}
3870+
}
37953871
get_todos_from_user:
37963872
| {
37973873
Args: {

0 commit comments

Comments
 (0)