Skip to content

Leave the provider default when an intercepted call has no commandTimeout - #232

Open
akashchamp wants to merge 1 commit into
DapperLib:mainfrom
akashchamp:fix/command-timeout-default-229
Open

akashchamp wants to merge 1 commit into
DapperLib:mainfrom
akashchamp:fix/command-timeout-default-229

Conversation

@akashchamp

Copy link
Copy Markdown

Fixes #229.

The generator forwarded commandTimeout.GetValueOrDefault(), so an intercepted call with no commandTimeout (or null) reached Command<TArgs>.GetCommand as 0 and replaced the provider default (the connection string Command Timeout, 30 s for SqlClient) with "no limit". It now forwards commandTimeout ?? -1 (or -1 when the method has no such parameter), which GetCommand already leaves alone. An explicit commandTimeout: 0 still means no limit. The public DapperAotExtensions.Command(...) overloads are untouched.

Single and multi-mapping generators are both changed; the generated-output snapshots (including the .netfx ones, edited by hand since only net10.0 runs here) and the sample in docs/generatedcode.md are updated.

Added SqliteTests.OmittedCommandTimeoutKeepsProviderDefault: an intercepted insert on a connection with DefaultTimeout = 1 while another connection holds the write lock. It fails with the old generated code (still waiting after 30 s) and passes now with database is locked after about a second.

dotnet test test/Dapper.AOT.Test -f net10.0: 381 passed, 0 failed.

…eout

The generator forwarded commandTimeout.GetValueOrDefault(), so an omitted
or null timeout reached Command<T>.GetCommand as 0 and removed the
provider default. Forward -1 instead, which GetCommand leaves alone; an
explicit 0 still means no limit.

Fixes DapperLib#229

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An intercepted call with no commandTimeout runs with CommandTimeout = 0 (no limit) instead of the provider's default

1 participant