Bug #100159 SQL with DateTime parameter returns String value

Submitted: 8 Jul 2020 15:11 Modified: 26 Aug 2020 14:18
Reporter: Andrey Belykh Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:8.0.20 OS:Windows
Assigned to: CPU Architecture:x86

[8 Jul 2020 15:11] Andrey Belykh
Description:
SQL with DateTime parameter returns String value

How to repeat:
using System;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
using MySql.Data.MySqlClient;
namespace ConsoleApp44
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "Data Source=DBTEST;Database=sakila;SslMode=None;User ID=root;Password=Dundas123;";
            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                string sql = "SELECT ?p0 as datevalue";
                using (MySqlCommand command = new MySqlCommand(sql, connection))
                {
                    command.Parameters.AddWithValue("?p0", DateTime.UtcNow);
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        using (DataTable schema = reader.GetSchemaTable())
                        {
                            MySqlDbType providerType = (MySqlDbType)schema.Rows[0].Field<int>(SchemaTableColumn.ProviderType);
                            Debug.WriteLine(providerType);
                        }
                    }
                }
            }
        }
    }
}
[8 Jul 2020 20:37] Andrey Belykh
Current (incorrect) output: VarChar

Expected output: DateTime
[9 Jul 2020 7:05] MySQL Verification Team
Hello Andrey,

Thank you for the report and test case.

regards,
Umesh
[24 Jul 2020 16:46] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 8.0.22 release, and here's the proposed changelog entry from the documentation team:

A valid query parameter of type DateTime was misinterpreted as a string
value.

Thank you for the bug report.
[26 Aug 2020 14:18] Andrey Belykh
Whens do you plan to release MySQL Connector/NET 8.0.22? Thanks.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.