Skip to content

Commit 8e4cad4

Browse files
committed
Add test for single quote and backslash in GUIDs.
1 parent affbb9c commit 8e4cad4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/SideBySide/InsertTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,38 @@ public void InsertDateTimeOffset()
166166
Assert.Equal(value.datetimeoffset1.Value.UtcDateTime, datetime);
167167
}
168168

169+
[Fact]
170+
public void InsertOldGuid()
171+
{
172+
var csb = AppConfig.CreateConnectionStringBuilder();
173+
csb.OldGuids = true;
174+
using (var connection = new MySqlConnection(csb.ConnectionString))
175+
{
176+
connection.Open();
177+
connection.Execute(@"drop table if exists old_guids;
178+
create table old_guids(id integer not null primary key auto_increment, guid binary(16) null);");
179+
180+
var guid = new Guid(1, 2, 3, 0x27, 0x5C, 0x7B, 0x7D, 0x22, 0x25, 0x26, 0x2C);
181+
182+
using (var cmd = connection.CreateCommand())
183+
{
184+
cmd.CommandText = @"insert into old_guids(guid) values(@guid)";
185+
var parameter = cmd.CreateParameter();
186+
parameter.ParameterName = "@guid";
187+
parameter.Value = guid;
188+
cmd.Parameters.Add(parameter);
189+
cmd.ExecuteNonQuery();
190+
}
191+
192+
using (var cmd = connection.CreateCommand())
193+
{
194+
cmd.CommandText = @"select guid from old_guids;";
195+
var selected = (Guid) cmd.ExecuteScalar();
196+
Assert.Equal(guid, selected);
197+
}
198+
}
199+
}
200+
169201
[Fact]
170202
public void InsertEnumValue()
171203
{

0 commit comments

Comments
 (0)