DapperLib / DapperLib/DapperAOT

SQLite IN clause fails in AOT mode with parameterized list (syntax error near "@Ids")

Open
#160 0 comments 6 reactions 0 assignees View on GitHub

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

  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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.