Skip to content

Fix for 20662. Linebreaks in HasData() in migration - #20699

Merged
lajones merged 1 commit into
masterfrom
20200420_Issue20662_01
Apr 22, 2020
Merged

lajones merged 1 commit into
masterfrom
20200420_Issue20662_01

Conversation

@lajones

@lajones lajones commented Apr 21, 2020

Copy link
Copy Markdown
Contributor

Fixes #20662

Generating the verbatim string literal syntax in the migration HasData() and snapshot BuildModel() code where the input data had line breaks in it caused problems because the code generators would add an additional indent at the newline and hence unintentionally add spaces to the string literal.

Now we generate "\r" and "\n" in non-verbatim strings instead.

@lajones
lajones requested a review from bricelam April 21, 2020 00:24
@lajones lajones self-assigned this Apr 21, 2020
? "@\"" + value.Replace("\"", "\"\"") + "\""
: "\"" + value.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
// do not use @"" syntax as in Migrations this can get indented at a newline and so add spaces to the literal
"\"" + value.Replace(@"\", @"\\").Replace("\"", "\\\"").Replace("\n", @"\n").Replace("\r", @"\r") + "\"";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you file an issue to use verbatim strings where it makes sense? (I always wanted us to generate @"...(localdb)\MSSQLLocalDB..." in OnConfiguring)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised #20723

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.

Seeding data via HasData that contains new lines includes undesired tabs when a migration is generated

2 participants