Dapper QueryMultiple throws "No columns were selected"

調試存儲過程發現某字段NULL,拼成的SQL最後啥也沒有了。。。
原因是存儲過程沒有執行到查詢SQL語句

QueryAsync throws "No columns were selected" when stored proc doesn't perform a select statement #591

Closed
 
 
toannguyen83 opened this issue on Aug 27, 2016 · 18 comments
 
Closed
 
 
 

Comments

@toannguyen83
 
 

Tested on Dapper 1.42 and 1.50.2

The following sql statement will simulate creating a temp stored proc and execute it with dapper

create procedure #TestProcedure
as
begin

    -- basically a failed if statement, so the select is not happening and the stored proc return nothing
    if 1=0
    begin
        select 
            'Password' as ColumnName,
            'Cannot be the same as your username' as [Message]
    end

end

exec #TestProcedure
 

When using Query version, it works fine and no results return. When using QueryAsync version, it throws "No columns were selected" error.

I attached a code sample using microsoft localdb. The sample project is using Dapper 1.50.2 and structure similar to the one I submitted in #501

DapperBugReplication20160827.zip

 
@adamhartford
 
 

I ran into this problem too. I also noticed that it works correctly in Mono, but not .NET.

 
@nickInMN
 
 
nickInMN commented on Jan 13, 2017 • 
edited 

I'm having this same problem. Is there any plan to get this fixed, it is a pretty serious issue. Having to query the database to get the object to update is cumbersome.

 
@andreujuanc
 
 

I can confirm that the issue affects async version of query, but it works fine otherwise.

 
@joaopgrassi
 
 
joaopgrassi commented on Sep 8, 2017 • 
edited 

Nothing on this? This is a real problem.. We have a bunch of procs that throw errors if the sensitive data you queried is not there:

IF @@ROWCOUNT = 0 RAISERROR ('User does not exists', 11, 1)

The database is old, and I'm not going to ask them to change 1000 procs to adjust to my code. multireader should expose some safe reader so we don't get these errors.

@alexbudisan
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章