Skip to content

feat(mssqlserver): support GO batch separator in init scripts - #11960

Draft
klouds27 wants to merge 1 commit into
testcontainers:mainfrom
klouds27:feat/11231-mssql-go-batch-separator
Draft

feat(mssqlserver): support GO batch separator in init scripts#11960
klouds27 wants to merge 1 commit into
testcontainers:mainfrom
klouds27:feat/11231-mssql-go-batch-separator

Conversation

@klouds27

@klouds27 klouds27 commented Aug 5, 2026

Copy link
Copy Markdown

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.

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Support the default GO batch separator for MSSQL

1 participant