isValid has no impact on transaction state #218
Conversation
Connection.isValid() should have no impact on transaction state See issue #214 for details.
I haven't tested this in detail, but it looks sane at a read and it passes in CI. Thanks for following up the report with a patch. |
Looks good by visual inspection. But does this actually detect when a connection has gone down? |
Yes, why do you question it ? |
@davecramer Because I didn't see a new unit test that checks if it actually does. If you have pre-existing unit tests that already do so then feel free to ignore my comment :) |
@cowwoc |
@alexismeneses Okay, so I withdraw my comment. Thanks guys. |
Only for a normal close. We probably should also test:
and a test where we unwrap the stream and close the underlying Socket or replace it with a simulated broken socket. However, as always, time is a factor. So I think this is a "patches are welcome" situation. |
Proposed fix for #214
As suggested by @ringerc,
isValid()
now sends an empty statement.Empty statements are then detected at lower level to prevent a BEGIN to be sent to the backend.