You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With regard to cancelling queries in Postgres, through context cancellation or other mechanism like pg_cancel_backend(), Postgres provides no guarantee that the query will actually be cancelled, and therefore might still complete normally.
The cancellation signal might or might not have any effect — for example, if it arrives after the backend has finished processing the query, then it will have no effect. If the cancellation is effective, it results in the current command being terminated early with an error message.
At the moment, sqlmock will always produce an error if we cancel the context passed into it.
In a highly concurrent system that supports query cancellation, we have observed this edge case happening often enough that we would like to test for it. So it would be nice if we could set up this scenario where the context is cancelled but sqlmock does not produce an error.
I hope to hear your opinion on this. If this sounds reasonable, I may be able to submit a PR. Though I admit I have not dived into the implementation of sqlmock to know how complex this might be.
Proposal
Perhaps something like .WillCompleteOnCancel().WillReturnRows(rows)
Use-cases
I would like to be able to test the case where the query might complete without error when the context is cancelled.
The text was updated successfully, but these errors were encountered:
Hi! Thank you for this useful library!
With regard to cancelling queries in Postgres, through context cancellation or other mechanism like
pg_cancel_backend()
, Postgres provides no guarantee that the query will actually be cancelled, and therefore might still complete normally.From Postgres docs:
At the moment, sqlmock will always produce an error if we cancel the context passed into it.
In a highly concurrent system that supports query cancellation, we have observed this edge case happening often enough that we would like to test for it. So it would be nice if we could set up this scenario where the context is cancelled but sqlmock does not produce an error.
I hope to hear your opinion on this. If this sounds reasonable, I may be able to submit a PR. Though I admit I have not dived into the implementation of sqlmock to know how complex this might be.
Proposal
Perhaps something like
.WillCompleteOnCancel().WillReturnRows(rows)
Use-cases
I would like to be able to test the case where the query might complete without error when the context is cancelled.
The text was updated successfully, but these errors were encountered: