Skip to content

Conversation

@marktech0813
Copy link

Summary of impact:

  • Fixes issue where ScriptUtils produced invalid SQL by converting required newlines between adjacent string literals into spaces.
  • Preserves compatibility with existing behavior for general whitespace/eol shrinking, only inserting a newline when it is necessary for adjacent quoted strings.

I identified the whitespace-collapsing logic in ScriptSplitter that turned EOLs into spaces, which broke PostgreSQL’s adjacent string literal concatenation when a newline is required between literals.
I updated ScriptSplitter to defer whitespace emission and only preserve a newline when the whitespace contains an EOL and it separates two quoted strings; otherwise it still collapses to a single space. This keeps current behavior broadly intact while fixing the bug.
I added a unit test to assert the specific case you reported.

…yntax testcontainers#11206

I've implemented the whitespace handling fix in ScriptSplitter to preserve a newline only when whitespace with an EOL appears between two quoted strings, and added a unit test to cover the reported case. 

I identified the whitespace-collapsing logic in ScriptSplitter that turned EOLs into spaces, which broke PostgreSQL’s adjacent string literal concatenation when a newline is required between literals.

I updated ScriptSplitter to defer whitespace emission and only preserve a newline when the whitespace contains an EOL and it separates two quoted strings; otherwise it still collapses to a single space. This keeps current behavior broadly intact while fixing the bug.
I added a unit test to assert the specific case you reported.
Added test in modules/database-commons/src/test/java/org/testcontainers/ext/ScriptSplittingTest.java:
testAdjacentStringLiteralsSeparatedByNewlineArePreserved checks that:
- CREATE TABLE collapses newlines to spaces.
- COMMENT ON COLUMN ... IS 'First sentence. '\n'Second sentence' preserves the required newline between quoted strings.
@marktech0813 marktech0813 requested a review from a team as a code owner November 11, 2025 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant