Open oriches opened 12 months ago
Please indicate what version you're using. I think this is already fixed; this works without any warnings:
var ids = new List<int> { 1, 2, 3 };
_ = conn.Query<string>("""
select A, B, C
from SomeTable
where Id in @ids
order by [SecId]
""", new { ids });
0.5.0-beta.102
can you show a concrete example then? because I can't repro - it does the right thing; also, make sure you've shut down the IDE - changing analyzer versions when devenv is open: is hit and miss
This is strange - was still doing it after restart, but now it has stopped, but now seem to have found a bug in Dapper (which I can;t believe...):
I have parameters declared as follows (id's are integers)
var parameters - new
{
ids = ids.OrderBy(id => id)
}
When I use a sql statement with the explicit '(' ')' characters around the @Ids parameter I get a sql exception, e.,g
'WHERE [A] IN (@Ids) ORDER BY [B];'
causes the following exception message - "Incorrect syntax near ','."
That's not a bug - it is a usage error, i.e. "don't do that" (when the parameter is going to be expanded). But it is something we can detect and issue guidance about in the analyzer. Are you happy for me to repurpose this ticket to track that?
Btw, the LINQ order-by on the arg items shouldn't matter, at least semantically
Happy to re-purpose
Is list expansion currently unsupported for MySqlConnection? With Dapper.AOT I am getting the following runtime exception (using the sample code from first comment).
System.NotSupportedException: 'Parameter type List`1 is not supported; see https://fl.vu/mysql-param-type. Value: System.Collections.Generic.List`1[System.Int32]'
Using version 1.0.14.
Is list expansion currently unsupported for MySqlConnection? With Dapper.AOT I am getting the following runtime exception (using the sample code from first comment).
System.NotSupportedException: 'Parameter type List`1 is not supported; see https://fl.vu/mysql-param-type. Value: System.Collections.Generic.List`1[System.Int32]'
Using version 1.0.14.
Having the same issue with MySqlConnector
SQL string looks something like "... WHERE [DividendId] IN @Ids ORDER BY [SecId];"
This caused error DAP206 Incorrect syntax near @Ids, but the code executes as expected without having the brackets around the IN parameter,
Should this be an Error or a Warning - if the code still works, it feels like a Warning, and the correction an advisory.