Skip to content

Commit

Permalink
Add test for single quote and backslash in GUIDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrainger committed May 26, 2017
1 parent affbb9c commit 8e4cad4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/SideBySide/InsertTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,38 @@ public void InsertDateTimeOffset()
Assert.Equal(value.datetimeoffset1.Value.UtcDateTime, datetime);
}

[Fact]
public void InsertOldGuid()
{
var csb = AppConfig.CreateConnectionStringBuilder();
csb.OldGuids = true;
using (var connection = new MySqlConnection(csb.ConnectionString))
{
connection.Open();
connection.Execute(@"drop table if exists old_guids;
create table old_guids(id integer not null primary key auto_increment, guid binary(16) null);");

var guid = new Guid(1, 2, 3, 0x27, 0x5C, 0x7B, 0x7D, 0x22, 0x25, 0x26, 0x2C);

using (var cmd = connection.CreateCommand())
{
cmd.CommandText = @"insert into old_guids(guid) values(@guid)";
var parameter = cmd.CreateParameter();
parameter.ParameterName = "@guid";
parameter.Value = guid;
cmd.Parameters.Add(parameter);
cmd.ExecuteNonQuery();
}

using (var cmd = connection.CreateCommand())
{
cmd.CommandText = @"select guid from old_guids;";
var selected = (Guid) cmd.ExecuteScalar();
Assert.Equal(guid, selected);
}
}
}

[Fact]
public void InsertEnumValue()
{
Expand Down

0 comments on commit 8e4cad4

Please sign in to comment.