@@ -213,10 +213,16 @@ public void Can_UpdateOnly_bool_columns()
213
213
{
214
214
db . DropAndCreateTable < PocoWithBool > ( ) ;
215
215
216
- db . Insert ( new PocoWithBool { Id = 1 , Bool = true } ) ;
217
- db . UpdateNonDefaults ( new PocoWithBool { Bool = false } , x => x . Id == 1 ) ;
216
+ db . Insert ( new PocoWithBool { Id = 1 , Bool = false } ) ;
218
217
var row = db . SingleById < PocoWithBool > ( 1 ) ;
219
218
Assert . That ( row . Bool , Is . False ) ;
219
+
220
+ db . UpdateNonDefaults ( new PocoWithBool { Bool = true } , x => x . Id == 1 ) ;
221
+ row = db . SingleById < PocoWithBool > ( 1 ) ;
222
+ Assert . That ( row . Bool , Is . True ) ;
223
+
224
+ Assert . Throws < ArgumentException > ( ( ) =>
225
+ db . UpdateNonDefaults ( new PocoWithBool { Bool = false } , x => x . Id == 1 ) ) ;
220
226
}
221
227
}
222
228
@@ -228,11 +234,37 @@ public void Can_UpdateOnly_nullable_bool_columns()
228
234
db . DropAndCreateTable < PocoWithNullableBool > ( ) ;
229
235
230
236
db . Insert ( new PocoWithNullableBool { Id = 1 , Bool = true } ) ;
231
- db . UpdateNonDefaults ( new PocoWithNullableBool { Bool = false } , x => x . Id == 1 ) ;
232
237
var row = db . SingleById < PocoWithNullableBool > ( 1 ) ;
238
+ Assert . That ( row . Bool , Is . True ) ;
239
+
240
+ db . UpdateNonDefaults ( new PocoWithNullableBool { Bool = false } , x => x . Id == 1 ) ;
241
+ row = db . SingleById < PocoWithNullableBool > ( 1 ) ;
233
242
Assert . That ( row . Bool , Is . False ) ;
234
243
}
235
244
}
245
+
246
+ public class PocoWithNullableInt
247
+ {
248
+ public int Id { get ; set ; }
249
+ public int ? Int { get ; set ; }
250
+ }
251
+
252
+ [ Test ]
253
+ public void Can_UpdateOnly_nullable_int_columns ( )
254
+ {
255
+ using ( var db = OpenDbConnection ( ) )
256
+ {
257
+ db . DropAndCreateTable < PocoWithNullableInt > ( ) ;
258
+
259
+ db . Insert ( new PocoWithNullableInt { Id = 1 , Int = 1 } ) ;
260
+ var row = db . SingleById < PocoWithNullableInt > ( 1 ) ;
261
+ Assert . That ( row . Int , Is . EqualTo ( 1 ) ) ;
262
+
263
+ db . UpdateNonDefaults ( new PocoWithNullableInt { Int = 0 } , x => x . Id == 1 ) ;
264
+ row = db . SingleById < PocoWithNullableInt > ( 1 ) ;
265
+ Assert . That ( row . Int , Is . EqualTo ( 0 ) ) ;
266
+ }
267
+ }
236
268
}
237
269
238
270
[ CompositeIndex ( "FirstName" , "LastName" ) ]
0 commit comments