Skip to content

Commit a8096ad

Browse files
committed
Minor cleanup
1 parent 51d0217 commit a8096ad

3 files changed

Lines changed: 8 additions & 22 deletions

File tree

src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
241241

242242
// CONCAT_WS filters out nulls, but string.Join treats them as empty strings; so coalesce (which is a no-op for non-nullable
243243
// arguments).
244-
arguments[i + 1] = sqlArgument switch
245-
{
246-
ColumnExpression { IsNullable: false } => sqlArgument,
247-
SqlConstantExpression constantExpression => constantExpression.Value is null
248-
? _sqlExpressionFactory.Constant(string.Empty)
249-
: constantExpression,
250-
_ => Dependencies.SqlExpressionFactory.Coalesce(sqlArgument, _sqlExpressionFactory.Constant(string.Empty))
251-
};
244+
arguments[i + 1] = Dependencies.SqlExpressionFactory.Coalesce(sqlArgument, _sqlExpressionFactory.Constant(string.Empty));
252245
}
253246

254247
// CONCAT_WS never returns null; a null delimiter is interpreted as an empty string, and null arguments are skipped

src/EFCore.SqlServer/Query/Internal/Translators/SqlServerStringAggregateMethodTranslator.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,10 @@ public SqlServerStringAggregateMethodTranslator(
8080
}
8181
}
8282

83-
// STRING_AGG filters out nulls, but string.Join treats them as empty strings; coalesce unless we know we're aggregating over
84-
// a non-nullable column.
85-
if (sqlExpression is not ColumnExpression { IsNullable: false })
86-
{
87-
sqlExpression = _sqlExpressionFactory.Coalesce(
88-
sqlExpression,
89-
_sqlExpressionFactory.Constant(string.Empty, typeof(string)));
90-
}
83+
// STRING_AGG filters out nulls, but string.Join treats them as empty strings.
84+
sqlExpression = _sqlExpressionFactory.Coalesce(
85+
sqlExpression,
86+
_sqlExpressionFactory.Constant(string.Empty, typeof(string)));
9187

9288
// STRING_AGG returns null when there are no rows (or non-null values), but string.Join returns an empty string.
9389
return

src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteStringAggregateMethodTranslator.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,9 @@ public SqliteStringAggregateMethodTranslator(ISqlExpressionFactory sqlExpression
6060
return null;
6161
}
6262

63-
if (sqlExpression is not ColumnExpression { IsNullable: false })
64-
{
65-
sqlExpression = _sqlExpressionFactory.Coalesce(
66-
sqlExpression,
67-
_sqlExpressionFactory.Constant(string.Empty, typeof(string)));
68-
}
63+
sqlExpression = _sqlExpressionFactory.Coalesce(
64+
sqlExpression,
65+
_sqlExpressionFactory.Constant(string.Empty, typeof(string)));
6966

7067
if (source.Predicate != null)
7168
{

0 commit comments

Comments
 (0)