[release/5.0] SqlServer Migrations: Don't generate EXEC(CONCAT()) #23005
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.
Fixes #22611
Description
In 5.0 we started generating EXEC calls in idempotent migration SQL scripts to work around quirks in the SQL Server parser. Unfortunately, this code didn't integrate well with another change we made to generate CONCAT calls for string literals containing new lines. The resulting SQL--
EXEC(CONCAT(...))
--is invalid.Customer Impact
This will only affect users generating idempotent migration scripts containing seed data. One customer has reported it so far.
How found
Customer reported on RC2.
Test coverage
We have tests comparing the generated SQL against a baseline. However, we don't have any tests that execute the SQL scripts due to the complexity of executing scripts containing utility statements like GO that aren't supported by SqlClient and only work in tools like SSMS, SDT, and SQLCMD. We previously failed to manually verify that the scripts executed correctly. This verification has now been done for the current baselines.
Regression?
Yes, for certain scenarios from 3.1. Although some scripts would have failed in 3.1 because of the missing EXEC calls, others would have worked that are now broken in 5.0.
cc @Pilchie