File tree 3 files changed +34
-4
lines changed
Async/NHSpecificTest/GH3327
3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -59,5 +59,21 @@ WHERE NOT (
59
59
)" ) ;
60
60
Assert . That ( ( await ( q . ListAsync ( ) ) ) [ 0 ] , Is . EqualTo ( 0 ) ) ;
61
61
}
62
+
63
+ [ Test ]
64
+ public async Task NotNotExistsNegatedAsync ( )
65
+ {
66
+ using var log = new SqlLogSpy ( ) ;
67
+ using var session = OpenSession ( ) ;
68
+ var results = await ( session . CreateQuery (
69
+ @"SELECT COUNT(ROOT.Id)
70
+ FROM Entity AS ROOT
71
+ WHERE NOT (
72
+ NOT EXISTS (FROM ChildEntity AS CHILD WHERE CHILD.Parent = ROOT)
73
+ AND NOT ROOT.Name = 'Parent'
74
+ )" ) . ListAsync ( ) ) ;
75
+ Assert . That ( log . GetWholeLog ( ) , Does . Not . Contains ( " NOT " ) . IgnoreCase ) ;
76
+ Assert . That ( results . Count , Is . EqualTo ( 1 ) ) ;
77
+ }
62
78
}
63
79
}
Original file line number Diff line number Diff line change @@ -48,5 +48,21 @@ WHERE NOT (
48
48
)" ) ;
49
49
Assert . That ( q . List ( ) [ 0 ] , Is . EqualTo ( 0 ) ) ;
50
50
}
51
+
52
+ [ Test ]
53
+ public void NotNotExistsNegated ( )
54
+ {
55
+ using var log = new SqlLogSpy ( ) ;
56
+ using var session = OpenSession ( ) ;
57
+ var results = session . CreateQuery (
58
+ @"SELECT COUNT(ROOT.Id)
59
+ FROM Entity AS ROOT
60
+ WHERE NOT (
61
+ NOT EXISTS (FROM ChildEntity AS CHILD WHERE CHILD.Parent = ROOT)
62
+ AND NOT ROOT.Name = 'Parent'
63
+ )" ) . List ( ) ;
64
+ Assert . That ( log . GetWholeLog ( ) , Does . Not . Contains ( " NOT " ) . IgnoreCase ) ;
65
+ Assert . That ( results . Count , Is . EqualTo ( 1 ) ) ;
66
+ }
51
67
}
52
68
}
Original file line number Diff line number Diff line change @@ -300,10 +300,8 @@ public IASTNode NegateNode(IASTNode node)
300
300
node . Type = BETWEEN ;
301
301
node . Text = "{not}" + node . Text ;
302
302
return node ; // (NOT (NOT_BETWEEN a b) ) => (BETWEEN a b)
303
- /* This can never happen because this rule will always eliminate the child NOT.
304
- case NOT:
305
- return x.getFirstChild(); // (NOT (NOT x) ) => (x)
306
- */
303
+ case NOT :
304
+ return node . GetChild ( 0 ) ; // (NOT (NOT x) ) => (x)
307
305
default :
308
306
IASTNode not = ( IASTNode ) TreeAdaptor . Create ( NOT , "not" ) ;
309
307
not . AddChild ( node ) ;
You can’t perform that action at this time.
0 commit comments