Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix InsertExpression Byte Array property #344

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/FluentMigrator.Runner/Generators/Generic/GenericQuoter.cs
Expand Up @@ -21,10 +21,19 @@ public virtual string QuoteValue(object value)
if (value is double) {return FormatDouble((double)value);}
if (value is float) {return FormatFloat((float)value);}
if (value is decimal) { return FormatDecimal((decimal)value); }

if (value is byte[]) { return FormatByteArray((byte[])value); }
return value.ToString();
}

protected virtual string FormatByteArray(byte[] value)
{
var hex = new System.Text.StringBuilder((value.Length * 2)+2);
hex.Append("0x");
foreach (byte b in value)
hex.AppendFormat("{0:x2}", b);
return hex.ToString();
}

private string FormatDecimal(decimal value)
{
return value.ToString(CultureInfo.InvariantCulture);
Expand Down
Expand Up @@ -259,5 +259,12 @@ public void TrueIsFormattedAsOne()
quoter.QuoteValue(true)
.ShouldBe("1");
}

[Test]
public void ByteArrayIsFormattedWithQuotes()
{
quoter.QuoteValue(new byte[] { 0, 254, 13, 18, 125, 17 })
.ShouldBe("0x00fe0d127d11");
}
}
}