Skip to content

Commit 6d01a36

Browse files
committed
Use ANSI CROSS JOIN syntax for dialects supporting them instead of implicit join
1 parent 40bd25e commit 6d01a36

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

src/NHibernate/Dialect/Dialect.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,5 +2635,13 @@ public virtual ISQLExceptionConverter BuildSQLExceptionConverter()
26352635
// may override to return whatever is most appropriate for that vendor.
26362636
return new SQLStateConverter(ViolatedConstraintNameExtracter);
26372637
}
2638+
2639+
/// <summary>
2640+
/// Get the separator to use for definining cross joins when translating HQL queries.
2641+
/// <para>Typically this will be either [<tt> cross join </tt>] or [<tt>, </tt>]</para>
2642+
/// <para>Note that the spaces are important!</para>
2643+
/// </summary>
2644+
/// <remarks></remarks>
2645+
public virtual string CrossJoinSeparator => " cross join ";
26382646
}
26392647
}

src/NHibernate/Dialect/Oracle8iDialect.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public override string AddColumnString
3434
get { return "add"; }
3535
}
3636

37+
/// <inheritdoc />
38+
public override string CrossJoinSeparator => ", ";
39+
3740
public override string CascadeConstraintsString
3841
{
3942
get { return " cascade constraints"; }

src/NHibernate/Dialect/Oracle9iDialect.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public override string CurrentTimestampSQLFunctionName
2020
}
2121
}
2222

23+
public override string CrossJoinSeparator => " cross join ";
24+
2325
// Current_timestamp is a timestamp with time zone, so it can always be converted back to UTC.
2426
/// <inheritdoc />
2527
public override string CurrentUtcTimestampSQLFunctionName => "SYS_EXTRACT_UTC(current_timestamp)";

src/NHibernate/Dialect/SybaseASE15Dialect.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ public override string NullColumnString
123123
{
124124
get { return " null"; }
125125
}
126-
126+
127+
public override string CrossJoinSeparator => ", ";
128+
127129
public override bool QualifyIndexName
128130
{
129131
get { return false; }

src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ protected virtual void FromFragmentSeparator(IASTNode a)
213213
else if (right.RealOrigin == left || (right.RealOrigin != null && right.RealOrigin == left.RealOrigin))
214214
{
215215
// right represents a joins originating from left; or
216-
// both right and left reprersent joins originating from the same FromElement
216+
// both right and left represent joins originating from the same FromElement
217217
if (right.JoinSequence != null && right.JoinSequence.IsThetaStyle)
218218
{
219-
Out(", ");
219+
WriteCrossJoinSeparator();
220220
}
221221
else
222222
{
@@ -226,10 +226,15 @@ protected virtual void FromFragmentSeparator(IASTNode a)
226226
else
227227
{
228228
// these are just two unrelated table references
229-
Out(", ");
229+
WriteCrossJoinSeparator();
230230
}
231231
}
232232

233+
private void WriteCrossJoinSeparator()
234+
{
235+
Out(sessionFactory.Dialect.CrossJoinSeparator);
236+
}
237+
233238
protected virtual void NestedFromFragment(IASTNode d, IASTNode parent)
234239
{
235240
// check a set of parent/child nodes in the from-clause tree
@@ -246,7 +251,7 @@ protected virtual void NestedFromFragment(IASTNode d, IASTNode parent)
246251
// right represents a joins originating from left...
247252
if (right.JoinSequence != null && right.JoinSequence.IsThetaStyle)
248253
{
249-
Out(", ");
254+
WriteCrossJoinSeparator();
250255
}
251256
else
252257
{
@@ -257,7 +262,7 @@ protected virtual void NestedFromFragment(IASTNode d, IASTNode parent)
257262
{
258263
// not so sure this is even valid subtree. but if it was, it'd
259264
// represent two unrelated table references...
260-
Out(", ");
265+
WriteCrossJoinSeparator();
261266
}
262267
}
263268

0 commit comments

Comments
 (0)