Skip to content

Commit 44cf75c

Browse files
committed
Extract AppendWithClause
1 parent cee9163 commit 44cf75c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/NHibernate/Engine/TableGroupJoinHelper.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace NHibernate.Engine
88
{
9-
//Generates table group join if neccessary. Example of generated query wit table group join:
9+
//Generates table group join if neccessary. Example of generated query with table group join:
1010
// SELECT *
1111
// FROM Person person0_
1212
// INNER JOIN (
@@ -101,6 +101,13 @@ private static SqlString GetTableGroupJoinWithClause(SqlString[] withClauseFragm
101101
}
102102
}
103103

104+
AppendWithClause(fromFragment, isAssociationJoin, withClauseFragments);
105+
106+
return fromFragment.ToSqlString();
107+
}
108+
109+
private static void AppendWithClause(SqlStringBuilder fromFragment, bool hasConditions, SqlString[] withClauseFragments)
110+
{
104111
for (var i = 0; i < withClauseFragments.Length; i++)
105112
{
106113
var withClause = withClauseFragments[i];
@@ -109,20 +116,19 @@ private static SqlString GetTableGroupJoinWithClause(SqlString[] withClauseFragm
109116

110117
if (withClause.StartsWithCaseInsensitive(" and "))
111118
{
112-
if (!isAssociationJoin)
119+
if (!hasConditions)
113120
{
114121
withClause = withClause.Substring(4);
115122
}
116123
}
117-
else if (isAssociationJoin)
124+
else if (hasConditions)
118125
{
119126
fromFragment.Add(" and ");
120127
}
121128

122129
fromFragment.Add(withClause);
130+
hasConditions = true;
123131
}
124-
125-
return fromFragment.ToSqlString();
126132
}
127133
}
128134
}

0 commit comments

Comments
 (0)