@@ -10,38 +10,32 @@ public class Fixture : BugTestCase
10
10
[ OneTimeSetUp ]
11
11
public void OneTimeSetUp ( )
12
12
{
13
- using ( var session = OpenSession ( ) )
14
- using ( var t = session . BeginTransaction ( ) )
13
+ using var session = OpenSession ( ) ;
14
+ using var t = session . BeginTransaction ( ) ;
15
+ var parent = new Entity
15
16
{
16
- var parent = new Entity
17
- {
18
- Name = "Parent1" ,
19
- Children = { new ChildEntity { Name = "Child" , Child = new GrandChildEntity { Name = "GrandChild" } } }
20
- } ;
21
- session . Save ( parent ) ;
22
- parent = new Entity
23
- {
24
- Name = "Parent2" ,
25
- Children = { new ChildEntity { Name = "Child" , Child = new GrandChildEntity { Name = "XGrandChild" } } }
26
- } ;
27
- var other = new OtherEntity { Name = "ABC" , Entities = { parent } } ;
28
- parent . OtherEntity = other ;
29
- session . Save ( parent ) ;
30
- session . Save ( other ) ;
31
- t . Commit ( ) ;
32
- }
33
-
34
- Sfi . Statistics . IsStatisticsEnabled = true ;
17
+ Name = "Parent1" ,
18
+ Children = { new ChildEntity { Name = "Child" , Child = new GrandChildEntity { Name = "GrandChild" } } }
19
+ } ;
20
+ session . Save ( parent ) ;
21
+ parent = new Entity
22
+ {
23
+ Name = "Parent2" ,
24
+ Children = { new ChildEntity { Name = "Child" , Child = new GrandChildEntity { Name = "XGrandChild" } } }
25
+ } ;
26
+ var other = new OtherEntity { Name = "ABC" , Entities = { parent } } ;
27
+ parent . OtherEntity = other ;
28
+ session . Save ( parent ) ;
29
+ session . Save ( other ) ;
30
+ t . Commit ( ) ;
35
31
}
36
32
37
33
[ OneTimeTearDown ]
38
34
public void OneTimeTearDown ( )
39
35
{
40
- Sfi . Statistics . IsStatisticsEnabled = false ;
41
-
42
36
using var session = OpenSession ( ) ;
43
37
using var transaction = session . BeginTransaction ( ) ;
44
-
38
+
45
39
session . CreateQuery ( "delete from ChildEntity" ) . ExecuteUpdate ( ) ;
46
40
session . CreateQuery ( "delete from GrandChildEntity" ) . ExecuteUpdate ( ) ;
47
41
session . CreateQuery ( "delete from Entity" ) . ExecuteUpdate ( ) ;
@@ -153,14 +147,34 @@ grandChild.Name like 'A%'
153
147
OR otherEntity.Name like 'A%'
154
148
)
155
149
)" ) ;
150
+ yield return new ( "FROM ROOT.Children FoundViaGrandChildG" , @"
151
+ SELECT ROOT
152
+ FROM Entity AS ROOT
153
+ WHERE
154
+ EXISTS
155
+ (FROM ROOT.Children AS child
156
+ LEFT JOIN child.Child AS grandChild
157
+ WHERE
158
+ grandChild.Name like 'G%'
159
+ )" ) ;
160
+ yield return new ( "FROM ROOT.OtherEntity FoundViaOtherEntityA" , @"
161
+ SELECT ROOT
162
+ FROM Entity AS ROOT
163
+ WHERE
164
+ EXISTS
165
+ (FROM ROOT.OtherEntity AS otherEntity
166
+ LEFT JOIN ChildEntity AS child ON child.Parent = ROOT
167
+ LEFT JOIN child.Child AS grandChild
168
+ WHERE
169
+ grandChild.Name like 'A%'
170
+ OR otherEntity.Name like 'A%'
171
+ )" ) ;
156
172
}
157
173
158
174
[ Test , TestCaseSource ( nameof ( GetNoExceptionOnExecuteQueryTestCases ) ) ]
159
175
public void NoExceptionOnExecuteQuery ( TestCaseItem testCase )
160
176
{
161
177
using var session = OpenSession ( ) ;
162
- using var _ = session . BeginTransaction ( ) ;
163
-
164
178
var q = session . CreateQuery ( testCase . Hql ) ;
165
179
Assert . That ( q . List ( ) , Has . Count . EqualTo ( 1 ) ) ;
166
180
}
0 commit comments