feat: add support for CancellationToken in generated methods#420
feat: add support for CancellationToken in generated methods#420ballistic-booger wants to merge 6 commits into
Conversation
ballistic-booger
commented
Jun 25, 2026
- implement CancellationGen to handle optional CancellationToken threading
- update DbDriver to expose Cancellation property
- modify CommonGen to support cancellation arguments in method parameters and reader calls
- update multiple generator types (One, Many, Exec, ExecRows, ExecLastId, CopyFrom) to include CancellationToken in signatures and DB calls
- update MySqlConnector, Npgsql, and Sqlite drivers to pass CancellationToken to connection and command execution
- add withCancellationToken option to PluginOptions and RawOptions
- update README.md with documentation and usage examples for cancellation
- add unit tests for CancellationGen and integration tests for generated code across all engines
4763a95 to
58b0769
Compare
- implement CancellationGen to handle CancellationToken injection into generated method signatures and DB calls - update DbDriver and CommonGen to support cancellation arguments in async methods - thread CancellationToken into OpenConnectionAsync, ExecuteAsync, QueryAsync, and other database operations across MySqlConnector, Npgsql, and Sqlite drivers - add WithCancellationToken option to PluginOptions and RawOptions - update README.md with documentation and examples for cancellation - add comprehensive unit tests for CancellationGen and end-to-end codegen validation - update example request files to include the new plugin option
58b0769 to
e1bd84d
Compare
…n option The withCancellationToken option was added to serialized plugin options, but only the Postgres request.message fixtures were regenerated. Regenerate the MySQL and SQLite ones so the codegen sync check passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@ballistic-booger Hi, need any help with this? 🙏 |
Apologies @doron050, I got pulled by other priorities. |
cd13999 to
3ff096c
Compare
doron050
left a comment
There was a problem hiding this comment.
Nice job! Take a look at the two comments I left, the rest looks solid 🎉
| { "anyarray", new() } | ||
| { "any", new() }, | ||
| { "anyarray", new() }, | ||
| { "hstore", new() } |
There was a problem hiding this comment.
364-366 Is this related in any way to the PR? if so I don't how
There was a problem hiding this comment.
Unrelated, sorry I forgot to pull this out into a different PR. I'll do that the moment I get a chance.
As for what this is, when sqlc is unable to determine the type, instead of throwing it'll just make it an object
There was a problem hiding this comment.
done with this, I'll follow up with these changes in a different PR
| var dapperArgs = CommonGen.GetDapperArgs(query); | ||
| var returnType = dbDriver.AddNullableSuffixIfNeeded(returnInterface, false); | ||
|
|
||
| if (dbDriver.Options.WithCancellationToken) |
There was a problem hiding this comment.
looks redundant, the dbDriver.Cancellation.WrapDapperArgs handles the default logic inside so just leave what's in the if as is (same for ManyDeclareGen, ExecDeclareGen and ExecRowsDeclareGen)
There was a problem hiding this comment.
sure thing 🫡
There was a problem hiding this comment.
I've pushed this now too 🙂, thanks for taking the time to review
3ff096c to
53e05ae
Compare
…edundant conditional checks - remove explicit check for WithCancellationToken in ExecDeclareGen, ExecRowsDeclareGen, ManyDeclareGen, and OneDeclareGen - use wrapped callArgs directly in all generated SQL execution methods