Skip to content

Commit

Permalink
! Patching MySQL's lack of support for filter conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
artiomchi committed May 21, 2019
1 parent 3ceeff1 commit 752d529
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ public override string GenerateCommand(string tableName, ICollection<ICollection
{
result.Append(" ON DUPLICATE KEY UPDATE ");
result.Append(string.Join(", ", updateExpressions
.Select((e, i) =>
{
var statement = $"{EscapeName(e.ColumnName)} = {ExpandValue(e.Value)}";
if (updateCondition != null)
statement = $"IF ({ExpandExpression(updateCondition)}, {statement}, {EscapeName(e.ColumnName)})";
return statement;
})));
.Select((e, i) => updateCondition != null
? $"{EscapeName(e.ColumnName)} = IF ({ExpandExpression(updateCondition)}, {ExpandValue(e.Value)}, {EscapeName(e.ColumnName)})"
: $"{EscapeName(e.ColumnName)} = {ExpandValue(e.Value)}")));
}
return result.ToString();
}
Expand Down

0 comments on commit 752d529

Please sign in to comment.