DapperLib / DapperAOT

Build time tools in the flavor of Dapper
Other
357 stars 19 forks source link

Possibly false positive DAP231 SELECT for single row without WHERE or (TOP and ORDER BY) (L1 C1) #52

Closed alex-belikov closed 11 months ago

alex-belikov commented 11 months ago

I'm getting this warning for query like this:

select HasRows = case when exists (select top 1 1 from MyTable) then 1 else 0 end

I believe the warning tried to prevent other issues, which might not be applicable for this query.

alex-belikov commented 11 months ago

Updating with full example:

public async Task<bool> HasRecordsExample()
{
    return await Conn().QueryFirstAsync<bool>(
        "select HasRecords = case when exists (select top 1 1 from MyTable) then 1 else 0 end");
}
mgravell commented 11 months ago

great report, thanks! fixed in the working branch, but it'll probably be a few days before I'm ready to merge that - a bit of a major refactor to get as much as possible off the generator pipe