Skip to content

Commit 47026d1

Browse files
update tests cases
1 parent b9e4d01 commit 47026d1

File tree

1 file changed

+218
-0
lines changed

1 file changed

+218
-0
lines changed

test/server/typegen.ts

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,18 @@ test('typegen: typescript', async () => {
158158
referencedRelation: "users_view"
159159
referencedColumns: ["id"]
160160
},
161+
{
162+
foreignKeyName: "todos_user-id_fkey"
163+
columns: ["user-id"]
164+
referencedRelation: "users_view_with_multiple_refs_to_users"
165+
referencedColumns: ["initial_id"]
166+
},
167+
{
168+
foreignKeyName: "todos_user-id_fkey"
169+
columns: ["user-id"]
170+
referencedRelation: "users_view_with_multiple_refs_to_users"
171+
referencedColumns: ["second_id"]
172+
},
161173
]
162174
}
163175
user_details: {
@@ -192,6 +204,18 @@ test('typegen: typescript', async () => {
192204
referencedRelation: "users_view"
193205
referencedColumns: ["id"]
194206
},
207+
{
208+
foreignKeyName: "user_details_user_id_fkey"
209+
columns: ["user_id"]
210+
referencedRelation: "users_view_with_multiple_refs_to_users"
211+
referencedColumns: ["initial_id"]
212+
},
213+
{
214+
foreignKeyName: "user_details_user_id_fkey"
215+
columns: ["user_id"]
216+
referencedRelation: "users_view_with_multiple_refs_to_users"
217+
referencedColumns: ["second_id"]
218+
},
195219
]
196220
}
197221
users: {
@@ -272,6 +296,18 @@ test('typegen: typescript', async () => {
272296
referencedRelation: "users_view"
273297
referencedColumns: ["id"]
274298
},
299+
{
300+
foreignKeyName: "todos_user-id_fkey"
301+
columns: ["user-id"]
302+
referencedRelation: "users_view_with_multiple_refs_to_users"
303+
referencedColumns: ["initial_id"]
304+
},
305+
{
306+
foreignKeyName: "todos_user-id_fkey"
307+
columns: ["user-id"]
308+
referencedRelation: "users_view_with_multiple_refs_to_users"
309+
referencedColumns: ["second_id"]
310+
},
275311
]
276312
}
277313
todos_view: {
@@ -309,6 +345,18 @@ test('typegen: typescript', async () => {
309345
referencedRelation: "users_view"
310346
referencedColumns: ["id"]
311347
},
348+
{
349+
foreignKeyName: "todos_user-id_fkey"
350+
columns: ["user-id"]
351+
referencedRelation: "users_view_with_multiple_refs_to_users"
352+
referencedColumns: ["initial_id"]
353+
},
354+
{
355+
foreignKeyName: "todos_user-id_fkey"
356+
columns: ["user-id"]
357+
referencedRelation: "users_view_with_multiple_refs_to_users"
358+
referencedColumns: ["second_id"]
359+
},
312360
]
313361
}
314362
users_view: {
@@ -329,6 +377,15 @@ test('typegen: typescript', async () => {
329377
}
330378
Relationships: []
331379
}
380+
users_view_with_multiple_refs_to_users: {
381+
Row: {
382+
initial_id: number | null
383+
initial_name: string | null
384+
second_id: number | null
385+
second_name: string | null
386+
}
387+
Relationships: []
388+
}
332389
}
333390
Functions: {
334391
blurb: {
@@ -696,6 +753,20 @@ test('typegen w/ one-to-one relationships', async () => {
696753
referencedRelation: "users_view"
697754
referencedColumns: ["id"]
698755
},
756+
{
757+
foreignKeyName: "todos_user-id_fkey"
758+
columns: ["user-id"]
759+
isOneToOne: false
760+
referencedRelation: "users_view_with_multiple_refs_to_users"
761+
referencedColumns: ["initial_id"]
762+
},
763+
{
764+
foreignKeyName: "todos_user-id_fkey"
765+
columns: ["user-id"]
766+
isOneToOne: false
767+
referencedRelation: "users_view_with_multiple_refs_to_users"
768+
referencedColumns: ["second_id"]
769+
},
699770
]
700771
}
701772
user_details: {
@@ -733,6 +804,20 @@ test('typegen w/ one-to-one relationships', async () => {
733804
referencedRelation: "users_view"
734805
referencedColumns: ["id"]
735806
},
807+
{
808+
foreignKeyName: "user_details_user_id_fkey"
809+
columns: ["user_id"]
810+
isOneToOne: true
811+
referencedRelation: "users_view_with_multiple_refs_to_users"
812+
referencedColumns: ["initial_id"]
813+
},
814+
{
815+
foreignKeyName: "user_details_user_id_fkey"
816+
columns: ["user_id"]
817+
isOneToOne: true
818+
referencedRelation: "users_view_with_multiple_refs_to_users"
819+
referencedColumns: ["second_id"]
820+
},
736821
]
737822
}
738823
users: {
@@ -816,6 +901,20 @@ test('typegen w/ one-to-one relationships', async () => {
816901
referencedRelation: "users_view"
817902
referencedColumns: ["id"]
818903
},
904+
{
905+
foreignKeyName: "todos_user-id_fkey"
906+
columns: ["user-id"]
907+
isOneToOne: false
908+
referencedRelation: "users_view_with_multiple_refs_to_users"
909+
referencedColumns: ["initial_id"]
910+
},
911+
{
912+
foreignKeyName: "todos_user-id_fkey"
913+
columns: ["user-id"]
914+
isOneToOne: false
915+
referencedRelation: "users_view_with_multiple_refs_to_users"
916+
referencedColumns: ["second_id"]
917+
},
819918
]
820919
}
821920
todos_view: {
@@ -856,6 +955,20 @@ test('typegen w/ one-to-one relationships', async () => {
856955
referencedRelation: "users_view"
857956
referencedColumns: ["id"]
858957
},
958+
{
959+
foreignKeyName: "todos_user-id_fkey"
960+
columns: ["user-id"]
961+
isOneToOne: false
962+
referencedRelation: "users_view_with_multiple_refs_to_users"
963+
referencedColumns: ["initial_id"]
964+
},
965+
{
966+
foreignKeyName: "todos_user-id_fkey"
967+
columns: ["user-id"]
968+
isOneToOne: false
969+
referencedRelation: "users_view_with_multiple_refs_to_users"
970+
referencedColumns: ["second_id"]
971+
},
859972
]
860973
}
861974
users_view: {
@@ -876,6 +989,15 @@ test('typegen w/ one-to-one relationships', async () => {
876989
}
877990
Relationships: []
878991
}
992+
users_view_with_multiple_refs_to_users: {
993+
Row: {
994+
initial_id: number | null
995+
initial_name: string | null
996+
second_id: number | null
997+
second_name: string | null
998+
}
999+
Relationships: []
1000+
}
8791001
}
8801002
Functions: {
8811003
blurb: {
@@ -1243,6 +1365,20 @@ test('typegen: typescript w/ one-to-one relationships', async () => {
12431365
referencedRelation: "users_view"
12441366
referencedColumns: ["id"]
12451367
},
1368+
{
1369+
foreignKeyName: "todos_user-id_fkey"
1370+
columns: ["user-id"]
1371+
isOneToOne: false
1372+
referencedRelation: "users_view_with_multiple_refs_to_users"
1373+
referencedColumns: ["initial_id"]
1374+
},
1375+
{
1376+
foreignKeyName: "todos_user-id_fkey"
1377+
columns: ["user-id"]
1378+
isOneToOne: false
1379+
referencedRelation: "users_view_with_multiple_refs_to_users"
1380+
referencedColumns: ["second_id"]
1381+
},
12461382
]
12471383
}
12481384
user_details: {
@@ -1280,6 +1416,20 @@ test('typegen: typescript w/ one-to-one relationships', async () => {
12801416
referencedRelation: "users_view"
12811417
referencedColumns: ["id"]
12821418
},
1419+
{
1420+
foreignKeyName: "user_details_user_id_fkey"
1421+
columns: ["user_id"]
1422+
isOneToOne: true
1423+
referencedRelation: "users_view_with_multiple_refs_to_users"
1424+
referencedColumns: ["initial_id"]
1425+
},
1426+
{
1427+
foreignKeyName: "user_details_user_id_fkey"
1428+
columns: ["user_id"]
1429+
isOneToOne: true
1430+
referencedRelation: "users_view_with_multiple_refs_to_users"
1431+
referencedColumns: ["second_id"]
1432+
},
12831433
]
12841434
}
12851435
users: {
@@ -1363,6 +1513,20 @@ test('typegen: typescript w/ one-to-one relationships', async () => {
13631513
referencedRelation: "users_view"
13641514
referencedColumns: ["id"]
13651515
},
1516+
{
1517+
foreignKeyName: "todos_user-id_fkey"
1518+
columns: ["user-id"]
1519+
isOneToOne: false
1520+
referencedRelation: "users_view_with_multiple_refs_to_users"
1521+
referencedColumns: ["initial_id"]
1522+
},
1523+
{
1524+
foreignKeyName: "todos_user-id_fkey"
1525+
columns: ["user-id"]
1526+
isOneToOne: false
1527+
referencedRelation: "users_view_with_multiple_refs_to_users"
1528+
referencedColumns: ["second_id"]
1529+
},
13661530
]
13671531
}
13681532
todos_view: {
@@ -1403,6 +1567,20 @@ test('typegen: typescript w/ one-to-one relationships', async () => {
14031567
referencedRelation: "users_view"
14041568
referencedColumns: ["id"]
14051569
},
1570+
{
1571+
foreignKeyName: "todos_user-id_fkey"
1572+
columns: ["user-id"]
1573+
isOneToOne: false
1574+
referencedRelation: "users_view_with_multiple_refs_to_users"
1575+
referencedColumns: ["initial_id"]
1576+
},
1577+
{
1578+
foreignKeyName: "todos_user-id_fkey"
1579+
columns: ["user-id"]
1580+
isOneToOne: false
1581+
referencedRelation: "users_view_with_multiple_refs_to_users"
1582+
referencedColumns: ["second_id"]
1583+
},
14061584
]
14071585
}
14081586
users_view: {
@@ -1423,6 +1601,15 @@ test('typegen: typescript w/ one-to-one relationships', async () => {
14231601
}
14241602
Relationships: []
14251603
}
1604+
users_view_with_multiple_refs_to_users: {
1605+
Row: {
1606+
initial_id: number | null
1607+
initial_name: string | null
1608+
second_id: number | null
1609+
second_name: string | null
1610+
}
1611+
Relationships: []
1612+
}
14261613
}
14271614
Functions: {
14281615
blurb: {
@@ -1804,6 +1991,13 @@ test('typegen: go', async () => {
18041991
Id sql.NullInt64 \`json:"id"\`
18051992
}
18061993
1994+
type PublicUsersViewWithMultipleRefsToUsersSelect struct {
1995+
InitialId sql.NullInt64 \`json:"initial_id"\`
1996+
InitialName sql.NullString \`json:"initial_name"\`
1997+
SecondId sql.NullInt64 \`json:"second_id"\`
1998+
SecondName sql.NullString \`json:"second_name"\`
1999+
}
2000+
18072001
type PublicTodosMatviewSelect struct {
18082002
Details sql.NullString \`json:"details"\`
18092003
Id sql.NullInt64 \`json:"id"\`
@@ -2151,6 +2345,18 @@ test('typegen: swift', async () => {
21512345
case status = "status"
21522346
}
21532347
}
2348+
internal struct UsersViewWithMultipleRefsToUsersSelect: Codable, Hashable, Sendable {
2349+
internal let initialId: Int64?
2350+
internal let initialName: String?
2351+
internal let secondId: Int64?
2352+
internal let secondName: String?
2353+
internal enum CodingKeys: String, CodingKey {
2354+
case initialId = "initial_id"
2355+
case initialName = "initial_name"
2356+
case secondId = "second_id"
2357+
case secondName = "second_name"
2358+
}
2359+
}
21542360
internal struct CompositeTypeWithArrayAttribute: Codable, Hashable, Sendable {
21552361
internal let MyTextArray: AnyJSON
21562362
internal enum CodingKeys: String, CodingKey {
@@ -2502,6 +2708,18 @@ test('typegen: swift w/ public access control', async () => {
25022708
case status = "status"
25032709
}
25042710
}
2711+
public struct UsersViewWithMultipleRefsToUsersSelect: Codable, Hashable, Sendable {
2712+
public let initialId: Int64?
2713+
public let initialName: String?
2714+
public let secondId: Int64?
2715+
public let secondName: String?
2716+
public enum CodingKeys: String, CodingKey {
2717+
case initialId = "initial_id"
2718+
case initialName = "initial_name"
2719+
case secondId = "second_id"
2720+
case secondName = "second_name"
2721+
}
2722+
}
25052723
public struct CompositeTypeWithArrayAttribute: Codable, Hashable, Sendable {
25062724
public let MyTextArray: AnyJSON
25072725
public enum CodingKeys: String, CodingKey {

0 commit comments

Comments
 (0)