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()
4747 }
4848 }
4949
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+
5070 [ Test ]
5171 public async Task EntityJoinForCompositeKeyAsync ( )
5272 {
Original file line number Diff line number Diff line change @@ -36,6 +36,26 @@ public void CanJoinNotAssociatedEntity()
3636 }
3737 }
3838
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+
3959 [ Test ]
4060 public void EntityJoinForCompositeKey ( )
4161 {
Original file line number Diff line number Diff line change @@ -259,6 +259,9 @@ fromJoin
259259
260260withClause
261261 : WITH^ logicalExpression
262+ | ON logicalExpression
263+ // it' s really just a WITH clause, so treat it as such.. .
264+ -> ^ (WITH[ " with" ] logicalExpression)
262265 ;
263266
264267fromRange
Original file line number Diff line number Diff line change @@ -1104,8 +1104,7 @@ public bool IsComparativeExpressionClause
11041104 {
11051105 get
11061106 {
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
11091108 return CurrentClauseType == WHERE ||
11101109 CurrentClauseType == WITH ||
11111110 IsInCase ;
You can’t perform that action at this time.
0 commit comments