Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected NotImplementedException: ConvertToMySqlDbType for Enum is not implemented #850

Closed
MaceWindu opened this issue Jul 16, 2020 · 7 comments
Assignees
Labels

Comments

@MaceWindu
Copy link
Contributor

@bgrainger,

We had strange exception from our CI Linux run with v0.69.6 recently. Never seen it before, so it could be some tricky bug in provider. Decided to report it.
There were 16 failing tests, all on same schema read query

SELECT SPECIFIC_SCHEMA, SPECIFIC_NAME, PARAMETER_MODE, ORDINAL_POSITION, PARAMETER_NAME, NUMERIC_PRECISION, NUMERIC_SCALE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, DTD_IDENTIFIER FROM INFORMATION_SCHEMA.parameters WHERE SPECIFIC_SCHEMA = database()
DataConnection: Error
Exception: MySql.Data.MySqlClient.MySqlException
Message  : Failed to read the result set.
   at MySql.Data.MySqlClient.MySqlDataReader.ActivateResultSet() in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlDataReader.cs:line 116
   at MySql.Data.MySqlClient.MySqlDataReader.CreateAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, IDictionary`2 cachedProcedures, IMySqlCommand command, CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlDataReader.cs:line 391
   at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(IReadOnlyList`1 commands, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/CommandExecutor.cs:line 62
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in /_/src/MySqlConnector/MySql.Data.MySqlClient/MySqlCommand.cs:line 210
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at LinqToDB.Data.DbCommandProcessor.DbCommandProcessorExtensions.ExecuteReaderExt(IDbCommand cmd, CommandBehavior commandBehavior) in d:\a\1\s\Source\LinqToDB\Data\DbCommandProcessor\DbCommandProcessorExtensions.cs:line 42
   at LinqToDB.Data.DataConnection.ExecuteReader(IDbCommand command, CommandBehavior commandBehavior) in d:\a\1\s\Source\LinqToDB\Data\DataConnection.cs:line 1387
   at LinqToDB.Data.DataConnection.ExecuteReader(CommandBehavior commandBehavior) in d:\a\1\s\Source\LinqToDB\Data\DataConnection.cs:line 1419

Exception: System.NotImplementedException
Message  : ConvertToMySqlDbType for Enum is not implemented
   at MySqlConnector.Core.TypeMapper.ConvertToMySqlDbType(ColumnDefinitionPayload columnDefinition, Boolean treatTinyAsBoolean, MySqlGuidFormat guidFormat) in /_/src/MySqlConnector/Core/TypeMapper.cs:line 276
   at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in /_/src/MySqlConnector/Core/ResultSet.cs:line 148

link to one of failed tests : https://dev.azure.com/linq2db/linq2db/_build/results?buildId=2690&view=ms.vss-test-web.build-test-results-tab&runId=50096&resultId=101991&paneView=attachments

Full nunit test log
_fv-az774_2020-07-15_13_47_49.zip

@MaceWindu
Copy link
Contributor Author

Actually it could be caused by new version of mysql. We use mysql:latest image, which was updated just recently to 8.0.21.

Probably now parameters table use enum (e.g. for PARAMETER_MODE column), but cannot see it in release notes https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-21.html

@bgrainger
Copy link
Member

I can confirm that INFORMATION_SCHEMA.parameters.PARAMETER_MODE has changed from CHAR(5) to ENUM between MySQL 8.0.20 and MySQL 8.0.21, and that does appear to be triggering the bug.

@bgrainger bgrainger self-assigned this Jul 16, 2020
@bgrainger bgrainger added the bug label Jul 16, 2020
@bgrainger
Copy link
Member

The integration tests already test ENUM columns but apparently the metadata for the PARAMETER_MODE column is different.

create table datatypes_enums(
rowid integer not null primary key auto_increment,
size enum('x-small', 'small', 'medium', 'large', 'x-large'),
color enum('red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet') not null
);
insert into datatypes_enums(size, color)
values
(null, 'red'),
('small', 'orange'),
('medium', 'green');

@bgrainger
Copy link
Member

The parameters.PARAMETER_MODE column metadata:
image

The datatypes_enums.size column metadata:
image

I don't yet know why these are different.

@bgrainger
Copy link
Member

This is fixed in 0.69.7; there's no fix in the 1.x branch yet.

Thanks for the concise and accurate bug report!

@bgrainger
Copy link
Member

Fix for 1.x is in 1.0.1-beta.0.8 in GitHub packages.

@bgrainger
Copy link
Member

Fixed in 1.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants