Skip to content

Throwing NullReferenceException when passing null parameter value to Query (MySqlParameter) #126

Description

@alanprot

To reproduce :

const string query = "select Col1 from Table1 where @parameter is null OR Col2 = @parameter";

using (var cmd = new MySqlCommand(query, con))
{
    cmd.Parameters.Add(new MySqlParameter() { ParameterName = "@parameter", Value = null });
    await cmd.ExecuteNonQueryAsync(cancellationToken);
}

Stack Trace:

at System.Object.GetType()
   at MySql.Data.MySqlClient.MySqlParameter.AppendSqlString(BinaryWriter writer, StatementPreparerOptions options)
   at MySql.Data.MySqlClient.MySqlStatementPreparer.ParameterSqlParser.DoAppendParameter(Int32 parameterIndex, Int32 textIndex, Int32 textLength)
   at MySql.Data.MySqlClient.MySqlParser.Parse(String sql)
   at MySql.Data.MySqlClient.MySqlStatementPreparer.ParseAndBindParameters()
   at MySql.Data.MySqlClient.MySqlCommand.<ExecuteReaderAsync>d__50.MoveNext()

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions