Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Missed CancellationToken for QueryAsync with an arbitrary number of input types

Open Dardjiling opened this issue 6 years ago • 12 comments

In methods QueryAsync with an arbitrary number of input types missed CancellationToken. In this methods initialized CommandDefinition with default(CancellationToken). CancellationToken should be moved to method parameters.

https://github.com/StackExchange/Dapper/blob/82a005953573b00b1d4c39e43568fb45449dd8e4/Dapper/SqlMapper.Async.cs#L974

Dardjiling avatar Jan 23 '19 09:01 Dardjiling

We're experiencing the same problem. Would be better to add an overload that takes a CommandDefinition instead of sql string, as the rest of methods, but with the Type[]

AndreaCuneo avatar Jan 24 '19 08:01 AndreaCuneo

We're racking up items for the 2.0 timeframe...adding cancellation tokens everywhere will be included. We have another big project in the pipe first (porting Stack Overflow to .NET Core), so I don't have a timeline. I just wanted to say: yes, this is planned.

NickCraver avatar Jan 27 '19 13:01 NickCraver

Great, I'll be waiting for this change I need to add the cancellationToken to the queries so all the processes end smoothly.

mentadev avatar Mar 07 '19 19:03 mentadev

Any progress on this issue?

It would help with this SqlKata issue: https://github.com/sqlkata/querybuilder/issues/302

tb-mtg avatar Oct 02 '19 04:10 tb-mtg

@NickCraver would you be willing to accept a PR with this change? If so, could we discuss what you had in mind?

baleeds avatar Nov 18 '20 13:11 baleeds

@NickCraver would you be willing to take a quick look at my PR? It is a small non-breaking change that I think will resolve this issue satisfactorily for the community.

kevin-in-code avatar Feb 21 '21 23:02 kevin-in-code

Any progress on this?

supertx2 avatar Oct 20 '21 10:10 supertx2

@NickCraver I second this. Desperately needed.

STRATZ-Ken avatar Oct 27 '21 20:10 STRATZ-Ken

I'm surprised this is a 4 years old problem, I've also been having this same problem. I don't think it would be much of a hassle to implement a solution, are the contributors willing to accept a pull request for this? If I understood correctly, it's a matter of adding CancellationToken to the methods here:

https://github.com/DapperLib/Dapper/blob/a31dfd3dd4d7f3f2580bd33c877199d7ef3e3ef9/Dapper/SqlMapper.Async.cs#L25

Instead of passing default to the CommandDefinition, just allow an optional CancellationToken to be passed to the method and pass it forward to the CommandDefinition.

WashingtonARamos avatar Apr 28 '23 18:04 WashingtonARamos

I'd love to see this fixed as well. There's an open PR that adds an overload that takes a CommandDefinition. This seems to be sufficient (and non-breaking) because a CommandDefinition already contains a CancellationToken.

bkoelman avatar Apr 28 '23 21:04 bkoelman

any update on this?

andreamorello93 avatar Jan 15 '24 13:01 andreamorello93

Is there any roadmap on when this issue would be resolved?

There is already an open PR and apparently a plethora of people who'd be happy to contribute. I understand that the issue is about the breaking change in the binary for the existing consumers. So the question is in which version could this be tackled?

Thanks!

nemanja228 avatar May 15 '24 00:05 nemanja228