@@ -143,6 +143,18 @@ public async Task NullInequalityWithNotNullAsync()
143
143
144
144
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . Address . Street != null && o . Address . Street != o . NullableOutput ) ;
145
145
await ( ExpectAsync ( q , Does . Contain ( "Output is null" ) . IgnoreCase , InputSet , BothDifferent ) ) ;
146
+
147
+ await ( ExpectAsync ( session . Query < Customer > ( ) . Where ( o => o . CustomerId != null ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
148
+ await ( ExpectAsync ( session . Query < Customer > ( ) . Where ( o => null != o . CustomerId ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
149
+
150
+ await ( ExpectAsync ( session . Query < Customer > ( ) . Where ( o => o . CustomerId != "test" ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
151
+ await ( ExpectAsync ( session . Query < Customer > ( ) . Where ( o => "test" != o . CustomerId ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
152
+
153
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => o . Order . Customer . CustomerId != "test" ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
154
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => "test" != o . Order . Customer . CustomerId ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
155
+
156
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => o . Order . Customer . CompanyName != "test" ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
157
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => "test" != o . Order . Customer . CompanyName ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
146
158
}
147
159
148
160
[ Test ]
@@ -173,10 +185,10 @@ public async Task NullInequalityWithNotNullSubSelectAsync()
173
185
public async Task NullEqualityWithNotNullAsync ( )
174
186
{
175
187
var q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . Input == null ) ;
176
- await ( ExpectAsync ( q , Does . Not . Contain ( "or is null" ) . IgnoreCase , OutputSet , BothNull ) ) ;
188
+ await ( ExpectAsync ( q , Does . Contain ( "is null" ) . IgnoreCase , OutputSet , BothNull ) ) ;
177
189
178
190
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => null == o . Input ) ;
179
- await ( ExpectAsync ( q , Does . Not . Contain ( "or is null" ) . IgnoreCase , OutputSet , BothNull ) ) ;
191
+ await ( ExpectAsync ( q , Does . Contain ( "is null" ) . IgnoreCase , OutputSet , BothNull ) ) ;
180
192
181
193
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . InputNullability == AnotherEntityNullability . True ) ;
182
194
await ( ExpectAsync ( q , Does . Not . Contain ( "end is null" ) . IgnoreCase , BothNull , OutputSet ) ) ;
@@ -291,6 +303,15 @@ public async Task NullEqualityWithNotNullAsync()
291
303
292
304
q = session . Query < AnotherEntityRequired > ( ) . Where ( o => o . Address . Street != null && o . Address . Street == o . NullableOutput ) ;
293
305
await ( ExpectAsync ( q , Does . Not . Contain ( "Output is null" ) . IgnoreCase , BothSame ) ) ;
306
+
307
+ await ( ExpectAsync ( session . Query < Customer > ( ) . Where ( o => o . CustomerId == null ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
308
+ await ( ExpectAsync ( session . Query < Customer > ( ) . Where ( o => null == o . CustomerId ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
309
+ await ( ExpectAsync ( session . Query < Customer > ( ) . Where ( o => o . CustomerId == "test" ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
310
+ await ( ExpectAsync ( session . Query < Customer > ( ) . Where ( o => "test" == o . CustomerId ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
311
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => o . Order . Customer . CustomerId == "test" ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
312
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => "test" == o . Order . Customer . CustomerId ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
313
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => o . Order . Customer . CompanyName == "test" ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
314
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => "test" == o . Order . Customer . CompanyName ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
294
315
}
295
316
296
317
[ Test ]
@@ -377,6 +398,24 @@ public async Task NullEqualityAsync()
377
398
// Columns against columns
378
399
q = from x in session . Query < AnotherEntity > ( ) where x . Input == x . Output select x ;
379
400
await ( ExpectAsync ( q , BothSame , BothNull ) ) ;
401
+
402
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => o . Order . Customer . ContactName == null ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
403
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => null == o . Order . Customer . ContactName ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
404
+
405
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => o . Order . Customer . ContactName == "test" ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
406
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => "test" == o . Order . Customer . ContactName ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
407
+
408
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => null == o . Component . Property1 ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
409
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Component . Property1 == null ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
410
+
411
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => "test" == o . Component . Property1 ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
412
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Component . Property1 == "test" ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
413
+
414
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => null == o . Component . OtherComponent . OtherProperty1 ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
415
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Component . OtherComponent . OtherProperty1 == null ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
416
+
417
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => "test" == o . Component . OtherComponent . OtherProperty1 ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
418
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Component . OtherComponent . OtherProperty1 == "test" ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
380
419
}
381
420
382
421
[ Test ]
@@ -435,6 +474,24 @@ public async Task NullInequalityAsync()
435
474
// Columns against columns
436
475
q = from x in session . Query < AnotherEntity > ( ) where x . Input != x . Output select x ;
437
476
await ( ExpectAsync ( q , BothDifferent , InputSet , OutputSet ) ) ;
477
+
478
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => o . Order . Customer . ContactName != null ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
479
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => null != o . Order . Customer . ContactName ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
480
+
481
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => o . Order . Customer . ContactName != "test" ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
482
+ await ( ExpectAsync ( session . Query < OrderLine > ( ) . Where ( o => "test" != o . Order . Customer . ContactName ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
483
+
484
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => null != o . Component . Property1 ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
485
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Component . Property1 != null ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
486
+
487
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => "test" != o . Component . Property1 ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
488
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Component . Property1 != "test" ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
489
+
490
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => null != o . Component . OtherComponent . OtherProperty1 ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
491
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Component . OtherComponent . OtherProperty1 != null ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
492
+
493
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => "test" != o . Component . OtherComponent . OtherProperty1 ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
494
+ await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Component . OtherComponent . OtherProperty1 != "test" ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
438
495
}
439
496
440
497
[ Test ]
@@ -633,6 +690,15 @@ private async Task ExpectAsync(IQueryable<AnotherEntityRequired> q, IResolveCons
633
690
return ( await ( q . ToListAsync ( cancellationToken ) ) ) . OrderBy ( Key ) . ToList ( ) ;
634
691
}
635
692
693
+ private static async Task ExpectAsync < T > ( IQueryable < T > query , IResolveConstraint sqlConstraint , CancellationToken cancellationToken = default ( CancellationToken ) )
694
+ {
695
+ using ( var sqlLog = new SqlLogSpy ( ) )
696
+ {
697
+ var list = await ( query . ToListAsync ( cancellationToken ) ) ;
698
+ Assert . That ( sqlLog . GetWholeLog ( ) , sqlConstraint ) ;
699
+ }
700
+ }
701
+
636
702
private static string Key ( AnotherEntityRequired e )
637
703
{
638
704
return "Input=" + ( e . Input ?? "NULL" ) + ", Output=" + ( e . Output ?? "NULL" ) ;
0 commit comments