Skip to content

Commit 54988d4

Browse files
committed
Add test for MySql.Data bug.
1 parent 6eaab06 commit 54988d4

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

docs/content/tutorials/migrating-from-connector-net.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,4 @@ The following bugs in Connector/NET are fixed by switching to MySqlConnector. (~
290290
* [#103819](https://bugs.mysql.com/bug.php?id=103819): Can't use `StringBuilder` containing non-BMP characters as `MySqlParameter.Value`
291291
* [#104910](https://bugs.mysql.com/bug.php?id=104910): `MySqlConnectionStringBuilder.TryGetValue` always returns `false`
292292
* [#104913](https://bugs.mysql.com/bug.php?id=104913): Cannot execute stored procedure with backtick in name
293+
* [#105209](https://bugs.mysql.com/bug.php?id=105209): Timespan value of zero can't be read with prepared command

tests/SideBySide/QueryTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,33 @@ public void QueryDateTimeLiteral()
12901290
Assert.Equal(MySqlDbType.DateTime, providerType);
12911291
}
12921292

1293+
[SkippableTheory(Baseline = "https://bugs.mysql.com/bug.php?id=105209")]
1294+
[InlineData(false)]
1295+
[InlineData(true)]
1296+
public void QueryTimeSpan(bool prepare)
1297+
{
1298+
using var connection = new MySqlConnection(AppConfig.ConnectionString);
1299+
connection.Open();
1300+
1301+
connection.Execute(@"drop table if exists test_time;
1302+
create table test_time(id int auto_increment not null primary key, tm time not null);
1303+
insert into test_time(tm) values('00:00:00'),('01:01:01'),('00:00:00');");
1304+
1305+
string sql = "select tm from test_time order by id";
1306+
using var command = new MySqlCommand(sql, connection);
1307+
if (prepare)
1308+
command.Prepare();
1309+
1310+
using var reader = command.ExecuteReader();
1311+
Assert.True(reader.Read());
1312+
Assert.Equal(TimeSpan.Zero, reader.GetTimeSpan(0));
1313+
Assert.True(reader.Read());
1314+
Assert.Equal(new(1, 1, 1), reader.GetTimeSpan(0));
1315+
Assert.True(reader.Read());
1316+
Assert.Equal(TimeSpan.Zero, reader.GetTimeSpan(0));
1317+
Assert.False(reader.Read());
1318+
}
1319+
12931320
class BoolTest
12941321
{
12951322
public int Id { get; set; }

0 commit comments

Comments
 (0)