Skip to content

Commit

Permalink
Fix Linux build breaks
Browse files Browse the repository at this point in the history
Fix two issues building and testing on Linux introduced by #20304 (bad generated SQL for DefaultValue with line breaks /cc @lajones)
* Test literals were using machine line endings
* Replacement mechanism for new lines in literals did not handle a single `\n`

Fixes #20439
Fixes #20438
  • Loading branch information
ajcvickers committed Mar 28, 2020
1 parent 8771406 commit 6436169
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ private string EscapeLineBreaks(string value)
return $"{unicodePrefix}'{value}'";
}

if (value.Length == 1)
{
return value[0] == '\n' ? "CHAR(10)" : "CHAR(13)";
}

return ($"CONCAT({unicodePrefix}'" + value
.Replace("\r", $"', CHAR(13), {unicodePrefix}'")
.Replace("\n", $"', CHAR(10), {unicodePrefix}'") + "')")
Expand Down
10 changes: 2 additions & 8 deletions test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,8 @@ public virtual Task Create_table_with_comments()
[ConditionalFact]
public virtual Task Create_table_with_multiline_comments()
{
var tableComment = @"This is a multi-line
table comment.
More information can
be found in the docs.";
var columnComment = @"This is a multi-line
column comment.
More information can
be found in the docs.";
var tableComment = "This is a multi-line\r\ntable comment.\r\nMore information can\r\nbe found in the docs.";
var columnComment = "This is a multi-line\ncolumn comment.\nMore information can\nbe found in the docs.";

return Test(
builder => { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ [Name] nvarchar(max) NULL
DECLARE @description AS sql_variant;
SET @description = CONCAT(N'This is a multi-line', CHAR(13), CHAR(10), N'table comment.', CHAR(13), CHAR(10), N'More information can', CHAR(13), CHAR(10), N'be found in the docs.');
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'People';
SET @description = CONCAT(N'This is a multi-line', CHAR(13), CHAR(10), N'column comment.', CHAR(13), CHAR(10), N'More information can', CHAR(13), CHAR(10), N'be found in the docs.');
SET @description = CONCAT(N'This is a multi-line', CHAR(10), N'column comment.', CHAR(10), N'More information can', CHAR(10), N'be found in the docs.');
EXEC sp_addextendedproperty 'MS_Description', @description, 'SCHEMA', @defaultSchema, 'TABLE', N'People', 'COLUMN', N'Name';");
}

Expand Down

0 comments on commit 6436169

Please sign in to comment.