Skip to content

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

@7amou3

Description

@7amou3

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions