DapperLib / DapperLib/Dapper.Contrib

Dapper Contrib Insert Update not working

Open
#66 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
293
Forks
109
PR merge metrics
No merged PRs in 30d

Description

when i update dapper and contrib libs in to latest which is 1.50.4 Insert, Update throws exception. so i downgraded to Dapper in to 1.50.2 and Contrib in to 1.50.0 then works fine.

this is the exception that i'm getting

MySql.Data.MySqlClient.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1s () values ()' at
line 1 at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow,
Int64& insertedId) at
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean
force) at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior
behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition&
command) in C:\projects\dapper\Dapper\SqlMapper.cs:line 552 at
Dapper.SqlMapper.Execute(IDbConnection cnn, String sql, Object param,
IDbTransaction transaction, Nullable1 commandTimeout, Nullable1
commandType) in C:\projects\dapper\Dapper\SqlMapper.cs:line 443 at
MySqlAdapter.Insert(IDbConnection connection, IDbTransaction
transaction, Nullable1 commandTimeout, String tableName, String columnList, String parameterList, IEnumerable1 keyProperties, Object
entityToInsert) in
C:\projects\dapper\Dapper.Contrib\SqlMapperExtensions.cs:line 897

at
Dapper.Contrib.Extensions.SqlMapperExtensions.Insert[T](IDbConnection
connection, T entityToInsert, IDbTransaction transaction, Nullable1 commandTimeout) in C:\projects\dapper\Dapper.Contrib\SqlMapperExtensions.cs:line 355
at RecruiterinsiderPortal.Data.AgencyRegionRepository.Save(Int32 userId, List`1 regions) in C:\Empite\RI\RecruiterinsiderPortal\RecruiterinsiderPortal\libs\RecruiterinsiderPortal.Data\AgencyRegionRepository.cs:line 67

StackOverflow

thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with MySqlAdapter.Insert in SqlMapperExtensions.cs at line 897 and the Insert extension at line 355. Reproduce the exception using the reported Dapper and Dapper.Contrib versions and inspect the generated SQL around the invalid '1s () values ()' syntax. Done means Insert and Update work with the affected MySQL setup, with a regression test covering the failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, mysql
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.