DapperLib / DapperLib/Dapper.Contrib

Contrib Error inserting into a table having an Identity and a Computed columns

Open
#18 4 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

The insert error is:

System.Data.SQLite.SQLiteException: SQL logic error
near ")": syntax error

Apparently, the culprit is the following command
var cmd = $"INSERT INTO {tableName} ({columnList}) VALUES ({parameterList}); SELECT last_insert_rowid() id";
which is part of the Insert function of the Contrib SQL Mapper Extensions for the SQLite implementation. Because both fields are auto-generated, the column and parameter lists are empty and the command fails.

The following command does work:
INSERT INTO [<table name>] Default Values;

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 at the SQLite implementation's Contrib SQL Mapper Extensions Insert function and inspect how columnList and parameterList are assembled. Reproduce the case where both lists are empty and verify the generated-insert path against SQLite's DEFAULT VALUES syntax. Done means inserts succeed for a table containing only Identity and Computed columns and the generated id is returned.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sqlite
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.