DapperLib / DapperLib/DapperAOT
SQLite IN clause fails in AOT mode with parameterized list (syntax error near "@Ids")
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 472
- Forks
- 43
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 18
Description
When using SQLite with DapperAOT and passing a list of values into an IN clause, the following query fails in AOT mode:
public Task<int> RemoveRangeAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken)
{
const string sql = "DELETE FROM Users WHERE Id IN @Ids";
return db.ExecuteAsync(sql, new { Ids = ids.Select(s => s.ToString()) }, transaction: tx);
}
Error:
SQLite Error 1: 'near "@Ids": syntax error'
However, if I disable source generation for this method using [Dapper(false)], it works as expected.
[DapperAot(false)]
public Task<int> RemoveRangeAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken) { ... }
It seems like the AOT generator does not correctly expand or transform the parameter list in the IN clause for SQLite. This syntax works fine with classic Dapper (non-AOT) and also in other database engines (like SQL Server).
Environment:
- Database: SQLite
- DapperAOT version: 1.0.48
- .NET version: 9
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 with the RemoveRangeAsync reproducer in the issue and inspect the generated AOT command for the SQLite IN @Ids query, comparing it with classic Dapper behavior. Done means the parameterized list executes successfully in SQLite while source generation remains enabled, with a regression test covering the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sqlite
- Domain
- build-system, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100