File tree 2 files changed +55
-1
lines changed
2 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,9 @@ type Simplify<T> = T extends object ? { [K in keyof T]: T[K] } : T
131
131
type MergeDeep < New , Row > = {
132
132
[ K in keyof New | keyof Row ] : K extends keyof New
133
133
? K extends keyof Row
134
- ? // Check if the override is on a embeded relation (array)
134
+ ? Row [ K ] extends SelectQueryError < string >
135
+ ? New [ K ]
136
+ : // Check if the override is on a embeded relation (array)
135
137
New [ K ] extends any [ ]
136
138
? Row [ K ] extends any [ ]
137
139
? Array < Simplify < MergeDeep < NonNullable < New [ K ] [ number ] > , NonNullable < Row [ K ] [ number ] > > > >
Original file line number Diff line number Diff line change @@ -435,3 +435,55 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
435
435
>
436
436
> ( true )
437
437
}
438
+
439
+ // Test overrideTypes single object with error embeded relation
440
+ {
441
+ const result = await postgrest . from ( 'users' ) . select ( '*, somerelation(*)' ) . overrideTypes <
442
+ {
443
+ somerelation : { created_at : Date ; data : string }
444
+ } [ ]
445
+ > ( )
446
+ if ( result . error ) {
447
+ throw new Error ( result . error . message )
448
+ }
449
+ let data : typeof result . data
450
+ expectType <
451
+ TypeEqual <
452
+ typeof data ,
453
+ {
454
+ username : string
455
+ data : CustomUserDataType | null
456
+ age_range : unknown
457
+ catchphrase : unknown
458
+ status : 'ONLINE' | 'OFFLINE' | null
459
+ somerelation : { created_at : Date ; data : string }
460
+ } [ ]
461
+ >
462
+ > ( true )
463
+ }
464
+
465
+ // Test overrideTypes array object with error embeded relation
466
+ {
467
+ const result = await postgrest . from ( 'users' ) . select ( '*, somerelation(*)' ) . overrideTypes <
468
+ {
469
+ somerelation : { created_at : Date ; data : string } [ ]
470
+ } [ ]
471
+ > ( )
472
+ if ( result . error ) {
473
+ throw new Error ( result . error . message )
474
+ }
475
+ let data : typeof result . data
476
+ expectType <
477
+ TypeEqual <
478
+ typeof data ,
479
+ {
480
+ username : string
481
+ data : CustomUserDataType | null
482
+ age_range : unknown
483
+ catchphrase : unknown
484
+ status : 'ONLINE' | 'OFFLINE' | null
485
+ somerelation : { created_at : Date ; data : string } [ ]
486
+ } [ ]
487
+ >
488
+ > ( true )
489
+ }
You can’t perform that action at this time.
0 commit comments