@@ -474,26 +474,27 @@ public async Task NullEqualityAsync()
474
474
await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . CreatedBy . ModifiedBy . Id == 5 ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
475
475
await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => 5 == o . CreatedBy . ModifiedBy . Id ) , Does . Not . Contain ( "is null" ) . IgnoreCase ) ) ;
476
476
477
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort == o . NullableShort ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
478
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . Short == o . Short ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
479
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort == o . Short ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
480
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . Short == o . NullableShort ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
481
+
477
482
short value = 3 ;
478
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . NullableShort == value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
479
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => value == o . NullableShort ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
480
-
481
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . NullableShort . Value == value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
482
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => value == o . NullableShort . Value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
483
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Short == value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
484
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => value == o . Short ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
485
-
486
- var shouldCast = Sfi . Dialect is SQLiteDialect || // transparent cast is translated to sql
487
- Sfi . Dialect . TryGetCastTypeName ( NHibernateUtil . Int16 . SqlType , out var shortCast ) &&
488
- Sfi . Dialect . TryGetCastTypeName ( NHibernateUtil . Int32 . SqlType , out var intCast ) &&
489
- shortCast != intCast ;
490
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . NullableShort == 3 ) , shouldCast ? WithoutIsNullAndWithCast ( ) : WithoutIsNullAndWithoutCast ( ) ) ) ;
491
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => 3 == o . NullableShort ) , shouldCast ? WithoutIsNullAndWithCast ( ) : WithoutIsNullAndWithoutCast ( ) ) ) ;
492
-
493
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . NullableShort . Value == 3 ) , shouldCast ? WithoutIsNullAndWithCast ( ) : WithoutIsNullAndWithoutCast ( ) ) ) ;
494
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => 3 == o . NullableShort . Value ) , shouldCast ? WithoutIsNullAndWithCast ( ) : WithoutIsNullAndWithoutCast ( ) ) ) ;
495
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Short == 3 ) , shouldCast ? WithoutIsNullAndWithCast ( ) : WithoutIsNullAndWithoutCast ( ) ) ) ;
496
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => 3 == o . Short ) , shouldCast ? WithoutIsNullAndWithCast ( ) : WithoutIsNullAndWithoutCast ( ) ) ) ;
483
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort == value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
484
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => value == o . NullableShort ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
485
+
486
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort . Value == value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
487
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => value == o . NullableShort . Value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
488
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . Short == value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
489
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => value == o . Short ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
490
+
491
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort == 3L ) , WithoutIsNullAndWithoutCast ( ) ) ) ;
492
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => 3L == o . NullableShort ) , WithoutIsNullAndWithoutCast ( ) ) ) ;
493
+
494
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort . Value == 3L ) , WithoutIsNullAndWithoutCast ( ) ) ) ;
495
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => 3L == o . NullableShort . Value ) , WithoutIsNullAndWithoutCast ( ) ) ) ;
496
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . Short == 3L ) , WithoutIsNullAndWithoutCast ( ) ) ) ;
497
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => 3L == o . Short ) , WithoutIsNullAndWithoutCast ( ) ) ) ;
497
498
}
498
499
499
500
[ Test ]
@@ -583,26 +584,27 @@ public async Task NullInequalityAsync()
583
584
await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . CreatedBy . ModifiedBy . Id != 5 ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
584
585
await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => 5 != o . CreatedBy . ModifiedBy . Id ) , Does . Contain ( "is null" ) . IgnoreCase ) ) ;
585
586
587
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort != o . NullableShort ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
588
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . Short != o . Short ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
589
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort != o . Short ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
590
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . Short != o . NullableShort ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
591
+
586
592
short value = 3 ;
587
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . NullableShort != value ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
588
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => value != o . NullableShort ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
589
-
590
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . NullableShort . Value != value ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
591
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => value != o . NullableShort . Value ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
592
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Short != value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
593
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => value != o . Short ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
594
-
595
- var shouldCast = Sfi . Dialect is SQLiteDialect || // transparent cast is translated to sql
596
- Sfi . Dialect . TryGetCastTypeName ( NHibernateUtil . Int16 . SqlType , out var shortCast ) &&
597
- Sfi . Dialect . TryGetCastTypeName ( NHibernateUtil . Int32 . SqlType , out var intCast ) &&
598
- shortCast != intCast ;
599
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . NullableShort != 3 ) , shouldCast ? WithIsNullAndWithCast ( ) : WithIsNullAndWithoutCast ( ) ) ) ;
600
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => 3 != o . NullableShort ) , shouldCast ? WithIsNullAndWithCast ( ) : WithIsNullAndWithoutCast ( ) ) ) ;
601
-
602
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . NullableShort . Value != 3 ) , shouldCast ? WithIsNullAndWithCast ( ) : WithIsNullAndWithoutCast ( ) ) ) ;
603
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => 3 != o . NullableShort . Value ) , shouldCast ? WithIsNullAndWithCast ( ) : WithIsNullAndWithoutCast ( ) ) ) ;
604
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => o . Short != 3 ) , shouldCast ? WithoutIsNullAndWithCast ( ) : WithoutIsNullAndWithoutCast ( ) ) ) ;
605
- await ( ExpectAsync ( session . Query < User > ( ) . Where ( o => 3 != o . Short ) , shouldCast ? WithoutIsNullAndWithCast ( ) : WithoutIsNullAndWithoutCast ( ) ) ) ;
593
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort != value ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
594
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => value != o . NullableShort ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
595
+
596
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort . Value != value ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
597
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => value != o . NullableShort . Value ) , Does . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
598
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . Short != value ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
599
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => value != o . Short ) , Does . Not . Contain ( "is null" ) . IgnoreCase . And . Not . Contain ( "cast" ) ) ) ;
600
+
601
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort != 3L ) , WithIsNullAndWithoutCast ( ) ) ) ;
602
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => 3 != o . NullableShort ) , WithIsNullAndWithoutCast ( ) ) ) ;
603
+
604
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . NullableShort . Value != 3L ) , WithIsNullAndWithoutCast ( ) ) ) ;
605
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => 3L != o . NullableShort . Value ) , WithIsNullAndWithoutCast ( ) ) ) ;
606
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => o . Short != 3L ) , WithoutIsNullAndWithoutCast ( ) ) ) ;
607
+ await ( ExpectAsync ( db . NumericEntities . Where ( o => 3L != o . Short ) , WithoutIsNullAndWithoutCast ( ) ) ) ;
606
608
}
607
609
608
610
private IResolveConstraint WithIsNullAndWithoutCast ( )
0 commit comments