@@ -147,4 +147,40 @@ describe('update', () => {
147
147
. maybeSingle ( ) ;
148
148
expect ( data ?. username ) . toEqual ( `${ testRunPrefix } -username-4` ) ;
149
149
} ) ;
150
+
151
+ it ( 'should not throw error when primary key value is false' , async ( ) => {
152
+ const qb = {
153
+ update : vi . fn ( ) . mockReturnThis ( ) ,
154
+ eq : vi . fn ( ) . mockReturnThis ( ) ,
155
+ select : vi . fn ( ) . mockReturnThis ( ) ,
156
+ throwOnError : vi . fn ( ) . mockReturnThis ( ) ,
157
+ single : vi . fn ( ) . mockResolvedValue ( { data : null } ) ,
158
+ } ;
159
+
160
+ await expect (
161
+ buildUpdateFetcher ( qb as any , [ 'is_active' ] , {
162
+ stripPrimaryKeys : false ,
163
+ queriesForTable : ( ) => [ ] ,
164
+ } ) ( { is_active : false , username : 'testuser' } ) ,
165
+ ) . resolves . not . toThrow ( ) ;
166
+ expect ( qb . eq ) . toHaveBeenCalledWith ( 'is_active' , false ) ;
167
+ } ) ;
168
+
169
+ it ( 'should not throw error when primary key value is 0' , async ( ) => {
170
+ const qb = {
171
+ update : vi . fn ( ) . mockReturnThis ( ) ,
172
+ eq : vi . fn ( ) . mockReturnThis ( ) ,
173
+ select : vi . fn ( ) . mockReturnThis ( ) ,
174
+ throwOnError : vi . fn ( ) . mockReturnThis ( ) ,
175
+ single : vi . fn ( ) . mockResolvedValue ( { data : null } ) ,
176
+ } ;
177
+
178
+ await expect (
179
+ buildUpdateFetcher ( qb as any , [ 'id' ] , {
180
+ stripPrimaryKeys : false ,
181
+ queriesForTable : ( ) => [ ] ,
182
+ } ) ( { id : 0 , username : 'testuser' } ) ,
183
+ ) . resolves . not . toThrow ( ) ;
184
+ expect ( qb . eq ) . toHaveBeenCalledWith ( 'id' , 0 ) ;
185
+ } ) ;
150
186
} ) ;
0 commit comments