File tree Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,26 @@ public async Task CanJoinNotAssociatedEntityAsync()
47
47
}
48
48
}
49
49
50
+ [ Test ]
51
+ public async Task CanJoinNotAssociatedEntity_OnKeywordAsync ( )
52
+ {
53
+ using ( var sqlLog = new SqlLogSpy ( ) )
54
+ using ( var session = OpenSession ( ) )
55
+ {
56
+ EntityComplex entityComplex =
57
+ await ( session
58
+ . CreateQuery ( "select ex " +
59
+ "from EntityWithNoAssociation root " +
60
+ "left join EntityComplex ex on root.Complex1Id = ex.Id" )
61
+ . SetMaxResults ( 1 )
62
+ . UniqueResultAsync < EntityComplex > ( ) ) ;
63
+
64
+ Assert . That ( entityComplex , Is . Not . Null ) ;
65
+ Assert . That ( NHibernateUtil . IsInitialized ( entityComplex ) , Is . True ) ;
66
+ Assert . That ( sqlLog . Appender . GetEvents ( ) . Length , Is . EqualTo ( 1 ) , "Only one SQL select is expected" ) ;
67
+ }
68
+ }
69
+
50
70
[ Test ]
51
71
public async Task EntityJoinForCompositeKeyAsync ( )
52
72
{
Original file line number Diff line number Diff line change @@ -36,6 +36,26 @@ public void CanJoinNotAssociatedEntity()
36
36
}
37
37
}
38
38
39
+ [ Test ]
40
+ public void CanJoinNotAssociatedEntity_OnKeyword ( )
41
+ {
42
+ using ( var sqlLog = new SqlLogSpy ( ) )
43
+ using ( var session = OpenSession ( ) )
44
+ {
45
+ EntityComplex entityComplex =
46
+ session
47
+ . CreateQuery ( "select ex " +
48
+ "from EntityWithNoAssociation root " +
49
+ "left join EntityComplex ex on root.Complex1Id = ex.Id" )
50
+ . SetMaxResults ( 1 )
51
+ . UniqueResult < EntityComplex > ( ) ;
52
+
53
+ Assert . That ( entityComplex , Is . Not . Null ) ;
54
+ Assert . That ( NHibernateUtil . IsInitialized ( entityComplex ) , Is . True ) ;
55
+ Assert . That ( sqlLog . Appender . GetEvents ( ) . Length , Is . EqualTo ( 1 ) , "Only one SQL select is expected" ) ;
56
+ }
57
+ }
58
+
39
59
[ Test ]
40
60
public void EntityJoinForCompositeKey ( )
41
61
{
Original file line number Diff line number Diff line change @@ -259,6 +259,9 @@ fromJoin
259
259
260
260
withClause
261
261
: WITH^ logicalExpression
262
+ | ON logicalExpression
263
+ // it' s really just a WITH clause, so treat it as such.. .
264
+ -> ^ (WITH[ " with" ] logicalExpression)
262
265
;
263
266
264
267
fromRange
Original file line number Diff line number Diff line change @@ -1104,8 +1104,7 @@ public bool IsComparativeExpressionClause
1104
1104
{
1105
1105
get
1106
1106
{
1107
- // Note: once we add support for "JOIN ... ON ...",
1108
- // the ON clause needs to get included here
1107
+ //Note: "JOIN ... ON ..." case is treated as "JOIN ... WITH ..." by parser
1109
1108
return CurrentClauseType == WHERE ||
1110
1109
CurrentClauseType == WITH ||
1111
1110
IsInCase ;
You can’t perform that action at this time.
0 commit comments