File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -716,8 +716,8 @@ test('maybeSingle w/ throwOnError', async () => {
716
716
. from ( 'messages' )
717
717
. select ( )
718
718
. eq ( 'message' , 'i do not exist' )
719
- . throwOnError ( )
720
719
. maybeSingle ( )
720
+ . throwOnError ( )
721
721
. then ( undefined , ( ) => {
722
722
passes = false
723
723
} )
Original file line number Diff line number Diff line change @@ -98,13 +98,22 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
98
98
expectType < PostgrestSingleResponse < SelectQueryError < `Referencing missing column \`dat\`` > [ ] >> ( res )
99
99
}
100
100
101
- // throw on error
101
+ // throw on error on query
102
102
{
103
- const { data } = await postgrest
104
- . from ( 'users' )
105
- . select ( '*' )
106
- . returns < { a : string ; b : number } [ ] > ( )
107
- . throwOnError ( )
103
+ const { data } = await postgrest . from ( 'users' ) . select ( 'username' ) . throwOnError ( )
104
+ expectType < { username : string } [ ] > ( data )
105
+ }
106
+
107
+ // queries without throw on error have nullable results
108
+ {
109
+ const { data } = await postgrest . from ( 'users' ) . select ( 'username' )
110
+ expectType < { username : string } [ ] | null > ( data )
111
+ }
112
+
113
+ // throw on error on client
114
+ {
115
+ const strictClient = postgrest . throwOnError ( )
108
116
109
- expectType < { a : string ; b : number } > ( data [ 0 ] )
117
+ const { data } = await strictClient . from ( 'users' ) . select ( 'username' )
118
+ expectType < { username : string } [ ] > ( data )
110
119
}
You can’t perform that action at this time.
0 commit comments