Skip to content

Commit 4e3d1e5

Browse files
committed
string separator
1 parent ea1a11b commit 4e3d1e5

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

src/NHibernate/Criterion/InExpression.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private SqlString GetSqlString(ICriteriaQuery criteriaQuery, SqlString[] columns
7979
if (columns.Length <= 1 || criteriaQuery.Factory.Dialect.SupportsRowValueConstructorSyntaxInInList)
8080
{
8181
var wrapInParens = columns.Length > 1;
82-
SqlString comaSeparator = new SqlString(", ");
82+
const string comaSeparator = ", ";
8383
var singleValueParam = SqlStringHelper.Repeat(new SqlString(bogusParam), columns.Length, comaSeparator, wrapInParens);
8484

8585
var parameters = SqlStringHelper.Repeat(singleValueParam, Values.Length, comaSeparator, wrapInParens: false);
@@ -99,8 +99,10 @@ private SqlString GetSqlString(ICriteriaQuery criteriaQuery, SqlString[] columns
9999
var cols = new SqlString(
100100
" ( ",
101101
SqlStringHelper.Join(new SqlString(" = ", bogusParam, " and "), columns),
102-
new SqlString("= ", bogusParam, " ) "));
103-
cols = SqlStringHelper.Repeat(cols, Values.Length, new SqlString(" or "), wrapInParens: Values.Length > 1);
102+
"= ",
103+
bogusParam,
104+
" ) ");
105+
cols = SqlStringHelper.Repeat(cols, Values.Length, " or ", wrapInParens: Values.Length > 1);
104106
return cols;
105107
}
106108

src/NHibernate/Hql/Ast/ANTLR/Tree/ResultVariableRefNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private SqlString GetColumnPositionsString(int scalarColumnIndex)
6767

6868
private SqlString GetColumnNamesString(int scalarColumnIndex)
6969
{
70-
return SqlStringHelper.Join(new SqlString(", "), Walker.SelectClause.ColumnNames[scalarColumnIndex]);
70+
return SqlStringHelper.Join(", ", Walker.SelectClause.ColumnNames[scalarColumnIndex]);
7171
}
7272
}
7373
}

src/NHibernate/SqlCommand/SqlStringHelper.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ public static SqlString Join(SqlString separator, IEnumerable objects)
3131
return buf.ToSqlString();
3232
}
3333

34+
public static SqlString Join(string separator, IEnumerable objects)
35+
{
36+
SqlStringBuilder buf = new SqlStringBuilder();
37+
bool first = true;
38+
39+
foreach (object obj in objects)
40+
{
41+
if (!first)
42+
{
43+
buf.Add(separator);
44+
}
45+
46+
first = false;
47+
buf.AddObject(obj);
48+
}
49+
50+
return buf.ToSqlString();
51+
}
52+
3453

3554
public static SqlString[] Add(SqlString[] x, string sep, SqlString[] y)
3655
{
@@ -91,7 +110,7 @@ internal static SqlString ParametersList(List<Parameter> parameters)
91110
return builder.ToSqlString();
92111
}
93112

94-
internal static SqlString Repeat(SqlString placeholder, int count, SqlString separator, bool wrapInParens)
113+
internal static SqlString Repeat(SqlString placeholder, int count, string separator, bool wrapInParens)
95114
{
96115
if (count == 0)
97116
return SqlString.Empty;
@@ -101,7 +120,7 @@ internal static SqlString Repeat(SqlString placeholder, int count, SqlString sep
101120
? new SqlString("(", placeholder, ")")
102121
: placeholder;
103122

104-
var builder = new SqlStringBuilder((placeholder.Count + separator.Count) * count + 1);
123+
var builder = new SqlStringBuilder((placeholder.Count + 1) * count + 1);
105124

106125
if (wrapInParens)
107126
{

0 commit comments

Comments
 (0)