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

in clause of mysql caused exception #110

Open
sixwaaaay opened this issue Dec 30, 2023 · 1 comment
Open

in clause of mysql caused exception #110

sixwaaaay opened this issue Dec 30, 2023 · 1 comment

Comments

@sixwaaaay
Copy link

Describe the bug

wherer in clause of mysql caused exception

Where are you seeing this?

  • what Dapper/Dapper.StrongName version?
    Dapper Version="2.1.24"
  • what Dapper.AOT/Dapper.Advisor version?
    Dapper.AOT Version="1.0.31"
  • if relevant: what database backend?
    MySqlConnector Version="2.3.1"
    MySQL 8.2.0
  • dotnet version
    8.0.100

To Reproduce

await using var connection = new MySqlConnection(connectionString);
long[] longs = [1, 2, 3];

var comments = await connection.QueryAsync<Comment>(
    "SELECT * FROM comments WHERE id in @ids", new { ids = longs });

if aot is not enabled, is works well.
however, with aot enabled, it doesn't work.

Unhandled exception. System.NotSupportedException: Parameter type Int64[] is not supported; see https://fl.vu/mysql-param-type. Value: System.Int64[]
   at MySqlConnector.MySqlParameter.AppendSqlString(ByteBufferWriter writer, StatementPreparerOptions options) in /_/src/MySqlConnector/MySqlParameter.cs:line 559
   at MySqlConnector.Core.StatementPreparer.ParameterSqlParser.DoAppendParameter(Int32 parameterIndex, Int32 textIndex, Int32 textLength) in /_/src/MySqlConnector/Core/StatementPreparer.cs:line 77
   at MySqlConnector.Core.StatementPreparer.ParameterSqlParser.OnNamedParameter(Int32 index, Int32 length) in /_/src/MySqlConnector/Core/StatementPreparer.cs:line 65
   at MySqlConnector.Core.SqlParser.Parse(String sql) in /_/src/MySqlConnector/Core/SqlParser.cs:line 266
   at MySqlConnector.Core.StatementPreparer.ParseAndBindParameters(ByteBufferWriter writer) in /_/src/MySqlConnector/Core/StatementPreparer.cs:line 32
   at MySqlConnector.Core.SingleCommandPayloadCreator.WriteCommand(IMySqlCommand command, ByteBufferWriter writer, Boolean appendSemicolon, Boolean isFirstCommand, Boolean isLastCommand) in /_/src/MySqlConnector/Core/SingleCommandPayloadCreator.cs:line 266
   at MySqlConnector.Core.SingleCommandPayloadCreator.WriteQueryPayload(IMySqlCommand command, IDictionary`2 cachedProcedures, ByteBufferWriter writer, Boolean appendSemicolon, Boolean isFirstCommand, Boolean isLastCommand) in /_/src/MySqlConnector/Core/SingleCommandPayloadCreator.cs:line 77
   at MySqlConnector.Core.SingleCommandPayloadCreator.WriteQueryCommand(CommandListPosition& commandListPosition, IDictionary`2 cachedProcedures, ByteBufferWriter writer, Boolean appendSemicolon) in /_/src/MySqlConnector/Core/SingleCommandPayloadCreator.cs:line 45
   at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/CommandExecutor.cs:line 44
   at MySqlConnector.MySqlCommand.ExecuteReaderAsync(CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 357
   at MySqlConnector.MySqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 350

it seems like that the sql string when using aot is like

SELECT id, .... FROM comments WHERE id in ?

rather than

SELECT id, .... FROM comments WHERE id in (?, ?, ?)

Expected behavior

in clause of mysql works well like not using aot.

@tonven
Copy link

tonven commented Mar 6, 2024

Having the same issue for SQLConnector. Any workaround or fix?

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

No branches or pull requests

2 participants