Description:
The MySqlDataReader.GetSchemaTable method returns a schema table for the current result set. If an "auto_increment" column is being queried, it is expected that the "IsAutoIncrement" field in the row in the schema table representing that column will be True.
It was True in MySQL Connector/NET 9.6.0 and earlier. In 9.7.0 it now incorrectly returns False.
How to repeat:
Create test.cs as follows and execute 'dotnet run test.cs' (with .NET 10):
#:property PublishAot=false
// use 9.6.0 below to see the expected behavior in the previous version
#:package MySql.Data@9.7.0
using MySql.Data.MySqlClient;
using var connection = new MySqlConnection("...");
connection.Open();
using var command = new MySqlCommand("""
DROP TABLE IF EXISTS test;
CREATE TABLE test(rowid integer not null primary key auto_increment);
""", connection);
command.ExecuteNonQuery();
command.CommandText = "select rowid from test";
using (var reader = command.ExecuteReader())
{
// prints False; expected True
Console.WriteLine(reader.GetSchemaTable().Rows[0]["IsAutoIncrement"]);
}
await using (var reader = await command.ExecuteReaderAsync())
{
// prints False; expected True
Console.WriteLine((await reader.GetSchemaTableAsync()).Rows[0]["IsAutoIncrement"]);
}
Description: The MySqlDataReader.GetSchemaTable method returns a schema table for the current result set. If an "auto_increment" column is being queried, it is expected that the "IsAutoIncrement" field in the row in the schema table representing that column will be True. It was True in MySQL Connector/NET 9.6.0 and earlier. In 9.7.0 it now incorrectly returns False. How to repeat: Create test.cs as follows and execute 'dotnet run test.cs' (with .NET 10): #:property PublishAot=false // use 9.6.0 below to see the expected behavior in the previous version #:package MySql.Data@9.7.0 using MySql.Data.MySqlClient; using var connection = new MySqlConnection("..."); connection.Open(); using var command = new MySqlCommand(""" DROP TABLE IF EXISTS test; CREATE TABLE test(rowid integer not null primary key auto_increment); """, connection); command.ExecuteNonQuery(); command.CommandText = "select rowid from test"; using (var reader = command.ExecuteReader()) { // prints False; expected True Console.WriteLine(reader.GetSchemaTable().Rows[0]["IsAutoIncrement"]); } await using (var reader = await command.ExecuteReaderAsync()) { // prints False; expected True Console.WriteLine((await reader.GetSchemaTableAsync()).Rows[0]["IsAutoIncrement"]); }