feat(mssqlserver): support GO batch separator in init scripts - #11960
Draft
klouds27 wants to merge 1 commit into
Draft
feat(mssqlserver): support GO batch separator in init scripts#11960klouds27 wants to merge 1 commit into
klouds27 wants to merge 1 commit into
Conversation
…ntainers#11231) adds ScriptUtils.normalizeGoSeparator() which replaces standalone GO lines with ; using a regex that matches GO case-insensitively on its own line, guarding against false matches on identifiers like GOOD or GOTO. introduces a preprocessInitScript hook on JdbcDatabaseContainer so subclasses can transform script content before execution. the default implementation is a no-op. MSSQLServerContainer (both the current and the deprecated legacy class) override it to call normalizeGoSeparator, enabling scripts exported from sqlcmd or SSMS to work without manual editing. Signed-off-by: klouds27 <adalwolf@gmail.com>
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.
Closes #11231
Scripts exported from sqlcmd or SSMS use GO as a batch separator, which is not valid SQL and causes init script execution to fail. This change makes MSSQLServerContainer handle those scripts transparently.
ScriptUtils.normalizeGoSeparator() replaces standalone GO lines with ; using a regex that matches GO case-insensitively on its own line. The regex guards against false matches on identifiers like GOOD or GOTO_COL.
A preprocessInitScript hook is added to JdbcDatabaseContainer as a protected method returning the script unchanged by default. MSSQLServerContainer overrides it to call normalizeGoSeparator. Both the current and the deprecated legacy container class are updated.
Four unit tests cover basic replacement, case insensitivity, leading whitespace, and the inline identifier guard.