-
Notifications
You must be signed in to change notification settings - Fork 932
Fix #3725: DbBatchBatcher empty batch execution bug #3726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Good catch and thanks for the fix! My very personal reflection is that your tests should be included in the normal batcher tests, rather than as a NHSpecificTest. |
|
Good point! I'll move the tests |
40a8bce to
722f7f9
Compare
Add empty batch validation to DoExecuteBatch() and DoExecuteBatchAsync() to prevent InvalidOperationException when ExecuteBatch is called with no commands. This matches the pattern used in GenericBatchingBatcher.
|
I have updated the test to be more like the scenario I encountered the bug in and verified that the tests now fail without the fix on SQL Server |
|
I have tried with your test update and SQL Server: under net8, the test is ignored. Under net4.8, there is still no failure without your fix. With PostgreSQL, still no failures either. So, I am now launching the whole CI on your test to check if anything starts failing, see #3733. |
|
Did you use NHibernate.Driver.MicrosoftDataSqlClientDriver as the driver on .NET8? Wasn't ignored for me. On net4.8 it wont fail though as this bug only exists in the DbBatchBatcher afaik. Maybe it should be locked down to only run for .NET8 then. |

Fixes #3725
Description
DbBatchBatcherthrowsInvalidOperationExceptionwhen attempting to execute an empty batch, whileGenericBatchingBatcherandSqlClientBatchingBatcherhandle this scenario correctly.Root Cause
DbBatchBatcher.DoExecuteBatch()andDoExecuteBatchAsync()lack empty batch validation. WhenExecuteBatch()is called with an empty batch (
_currentBatch.BatchCommands.Count == 0), the code attempts to execute aDbBatchwith no commands, causing:
System.InvalidOperationException: ExecuteNonQuery: CommandText property has not been initialized
Changes
Added empty batch check at the beginning of both methods, matching the pattern used in
GenericBatchingBatcher:Modified:
Added: