Conversation
When a migration throws before calling execute(), its bindings remain on the shared query generator. Subsequent calls to SchemaChangeRepository::count() then inherit these stale bindings, causing MSSQL to fail with error 245 (varchar to int conversion) when the extra binding is passed to a mismatched placeholder. Changes: - Add resetBinding() in SchemaRunner::apply() and applyOne() catch blocks to clean up after failed migrations - Add defensive resetBinding() in SchemaChangeRepository::count() before building the query - Add resetBinding() at the start of update() in MySQLQuery and MSSQLQuery to prevent stale bindings from prior abandoned queries from corrupting update parameter binding Tests: - Add SchemaRunnerApplyMultipleTest covering apply() called multiple times, including the specific scenario of a failed migration leaving dirty bindings - Add StaleBindingsTest covering update and delete resilience against abandoned query bindings
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fix stale query parameter bindings leaking between queries, causing MSSQL error 245 (varchar to int conversion) when migrations fail before calling execute().
Motivation
In MSSQL environments, calling
SchemaRunner::apply()multiple times would crash with "Conversion failed when converting the varchar value ... to data type int" when a prior migration threw an exception before completing query execution, leaving dirty bindings on the shared query generator.Changes
resetBinding()inSchemaRunner::apply()andapplyOne()catch blocks to clean up after failed migrationsresetBinding()inSchemaChangeRepository::count()before building queriesresetBinding()at the start ofupdate()inMySQLQueryandMSSQLQuerySchemaRunnerApplyMultipleTest(16 tests) covering repeatedapply()calls and the dirty-bindings scenarioStaleBindingsTest(4 tests) covering update/delete resilience against abandoned query bindingsHow to Test / Verify
Unit tests covering SQLite, MySQL, and MSSQL:
php vendor/bin/phpunit --filter "SchemaRunnerApplyMultipleTest|StaleBindingsTest"Full suite passes (882 tests, 2535 assertions).
Breaking Changes and Migration Steps
None
Checklist
Related issues
Not Applicable