Bug #91770 TIME(n) column loses microseconds with prepared command
Submitted: 24 Jul 2018 4:40 Modified: 24 Jul 2018 4:54
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:8.0.11 OS:Microsoft Windows (10)
Assigned to: CPU Architecture:Any (x64)

[24 Jul 2018 4:40] Bradley Grainger
Description:
If MySqlCommand.Prepare() is called for a statement that SELECTs a TIME(n) column, the "microseconds" part is set to zero on the returned result. The microseconds should be set correctly whether or not MySqlCommand.Prepare is called.

How to repeat:
Run the following C# code:

// NOTE: MUST have IgnorePrepare=false in connection string
using (var connection = new MySqlConnection("...;IgnorePrepare=false"))
{
	connection.Open();
	using (var command = new MySqlCommand(@"
DROP TABLE IF EXISTS test_time;
CREATE TABLE test_time(data TIME(3) NOT NULL);
", connection))
		command.ExecuteNonQuery();

	using (var command = new MySqlCommand(@"INSERT INTO test_time VALUES(@data);", connection))
	{
		command.Parameters.AddWithValue("@data", new TimeSpan(1, 2, 3, 4, 567));
		command.ExecuteNonQuery();
	}

	using (var command = new MySqlCommand(@"SELECT data FROM test_time;", connection))
	{
		// *** this causes the bug ***
		command.Prepare();
		
		var result = (TimeSpan) command.ExecuteScalar();
		
		// prints 1.02:03:04, expected 1.02:03:04.56700000
		Console.WriteLine(result);
	}
}
[24 Jul 2018 4:54] Chiranjeevi Battula
Hello Bradley Grainger,

Thank you for the bug report and test case.
Verified this behavior on Visual Studio 2017 (C#.Net) and Connector/NET 8.0.11 version.

Thanks,
Chiranjeevi.
[24 Jul 2018 5:02] Chiranjeevi Battula
Screenshot

Attachment: Bug_91770.PNG (image/png, text), 69.86 KiB.