DapperLib / DapperLib/Dapper.Contrib
Remove "RETURNING *" or "RETURNING Id" in Dapper.Contrib
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 293
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
Currently, it seems to me that Dapper.Contrib's InsertAsync generates SQL with RETURNING, is there any way we can remove this with configuration? If not, supporting it would be great.
My problem is InsertAsync adds RETURNING Id at the end of my query. But my column name is "Id" with quotes. But when this query is sent to PostgreSQL, it gives this error: Column id does not exist. Removing the last returning clause will solve my problem because I'm not using any return value in my insert query.
Also, in PostgresAdapter, AddColumnName adds with quotes like this "Price", but adding returning clause adds without quotes like this: Id.
The code that causes "Column id does not exist" error:
[Table("\"Products\"")]
public class Product
{
public long Id { get; set; }
public string Name { get; set; }
}
public async Task<int> InsertAsync(IDbConnection connection, Product product)
{
return await connection.InsertAsync(product);
}
My database schema:
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting InsertAsync and PostgresAdapter, especially how the RETURNING clause is assembled versus AddColumnName. Reproduce the quoted "Id" example against PostgreSQL and determine the intended configuration or omission behavior. Done means InsertAsync no longer generates invalid unquoted RETURNING identifiers and the existing return-value behavior remains defined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100