Skip to content

Commit 5a65541

Browse files
committed
Fix adding strings not working
1 parent e6be0d2 commit 5a65541

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

SQLiteSharp/SqlBuilder.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,17 @@ public string ExpressionToSql(Expression expression, ParameterExpression rowExpr
408408
// Binary (a == b)
409409
case BinaryExpression binaryExpression:
410410
if (TryConvertEqualsNullToIsNull(binaryExpression, rowExpression, out string? isNullSql)) {
411+
// Null check uses special syntax
411412
return isNullSql;
412413
}
413414
if (binaryExpression.NodeType is ExpressionType.Coalesce) {
415+
// Coalesce uses method not operator
414416
return $"coalesce({ExpressionToSql(binaryExpression.Left, rowExpression)}, {ExpressionToSql(binaryExpression.Right, rowExpression)})";
415417
}
418+
if (binaryExpression.NodeType is ExpressionType.Add or ExpressionType.AddChecked && (binaryExpression.Left.Type == typeof(string) || binaryExpression.Right.Type == typeof(string))) {
419+
// Concatenating strings uses special operator
420+
return $"({ExpressionToSql(binaryExpression.Left, rowExpression)} || {ExpressionToSql(binaryExpression.Right, rowExpression)})";
421+
}
416422
return $"({ExpressionToSql(binaryExpression.Left, rowExpression)} {OperatorToSql(binaryExpression.NodeType)} {ExpressionToSql(binaryExpression.Right, rowExpression)})";
417423

418424
// Condition (a ? b : c)

0 commit comments

Comments
 (0)