jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM
Other
856 stars 145 forks source link

NullReferenceException using a stored procedure with a UUID input parameter #493

Closed elandev closed 4 months ago

elandev commented 1 year ago

Describe the bug

Getting a NullReferenceException with a stored procedure inserting into UUID column data type. I get the following NullReferenceException:

The stored procedure works, when I remove the UUID parameter from the stored procedure.

Object reference not set to an instance of an object.
   at MySqlConnector.Core.CachedParameter..ctor(Int32 ordinalPosition, String mode, String name, String dataType, Boolean unsigned, Int32 length)
   at MySqlConnector.Core.CachedProcedure.<FillAsync>d__0.MoveNext()
   at MySqlConnector.MySqlConnection.<GetCachedProcedure>d__87.MoveNext()
   at MySqlConnector.MySqlCommandBuilder.<DeriveParametersAsync>d__3.MoveNext()
   at MySqlConnector.MySqlCommandBuilder.DeriveParameters(MySqlCommand command)
   at Insight.Database.Providers.MySqlConnector.MySqlConnectorInsightDbProvider.DeriveParametersFromStoredProcedure(IDbCommand command)
   at Insight.Database.Providers.InsightDbProvider.<>c__DisplayClass13_0.<DeriveParameters>b__0(IDbConnection _)
   at Insight.Database.DBConnectionExtensions.ExecuteAndAutoClose[T](IDbConnection connection, Func`2 getCommand, Func`3 translate, CommandBehavior commandBehavior)
   at Insight.Database.Providers.InsightDbProvider.DeriveParameters(IDbCommand command)
   at Insight.Database.CodeGenerator.DbParameterGenerator.CreateClassInputParameterGenerator(IDbCommand command, Type type)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Insight.Database.DBCommandExtensions.AddParameters(IDbCommand cmd, Object parameters)
   at Insight.Database.DBConnectionExtensions.CreateCommand(IDbConnection connection, String sql, Object parameters, CommandType commandType, Nullable`1 commandTimeout, IDbTransaction transaction)
   at Insight.Database.DBConnectionExtensions.<>c__DisplayClass0_0.<ExecuteAsync>b__0(IDbConnection c)
   at Insight.Database.DBConnectionExtensions.<ExecuteAsyncAndAutoClose>d__36`1.MoveNext()
   at TestMySql.Program.<InsertSqlData>d__4.MoveNext() in C:\Dev\src\Scratch\TestMySqlUuid\Program.cs:line 107

Steps to reproduce

  1. Load the attached project with Visual Studio 2022.
  2. Set up MariaDB as the database (10.11.2-MariaDB).
  3. Edit the server, database name and credentials for the connection string.
  4. Restore Nuget packages and build the solution.
  5. Run the project.

The project is set up to run both tests with and without the UUID parameter. SQL insert statement works. Stored procedure works without UUID, but get the NullReferenceException when using the stored procedure with the UUID parameter.

Expected behavior

Expected the stored procedure insert with the UUID to work.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

elandev commented 1 year ago

This issue still exists. Is there an update on this?

stale[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jonwagner commented 4 months ago

Unfortunately, we can't accept project zip files as reproduction cases. Please paste sufficient code to reproduce here, or submit a PR with a failing test case.