Skip to content

Commit

Permalink
Put RETURNING on its own line
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Mar 5, 2022
1 parent 466fe62 commit f81b86d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/EFCore.Relational/Update/UpdateSqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ protected virtual void AppendReturningClause(
if (operations.Count > 0)
{
commandStringBuilder
.Append(" RETURNING ")
.AppendLine()
.Append("RETURNING ")
.AppendJoin(
operations,
SqlGenerationHelper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,12 @@ private void AppendOutputClause(

if (additionalColumns != null)
{
commandStringBuilder
.Append(", ").Append(additionalColumns);
if (operations.Count > 0)
{
commandStringBuilder.Append(", ");
}

commandStringBuilder.Append(additionalColumns);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,42 @@ public override void GenerateNextSequenceValueOperation_returns_statement_with_s
protected override void AppendInsertOperation_insert_if_store_generated_columns_exist_verification(StringBuilder stringBuilder)
=> AssertBaseline(
@"INSERT INTO ""Ducks"" (""Name"", ""Quacks"", ""ConcurrencyToken"")
VALUES (@p0, @p1, @p2) RETURNING ""Id"", ""Computed"";
VALUES (@p0, @p1, @p2)
RETURNING ""Id"", ""Computed"";
",
stringBuilder.ToString());

protected override void AppendInsertOperation_for_store_generated_columns_but_no_identity_verification(
StringBuilder stringBuilder)
=> AssertBaseline(
@"INSERT INTO ""Ducks"" (""Id"", ""Name"", ""Quacks"", ""ConcurrencyToken"")
VALUES (@p0, @p1, @p2, @p3) RETURNING ""Computed"";
VALUES (@p0, @p1, @p2, @p3)
RETURNING ""Computed"";
",
stringBuilder.ToString());

protected override void AppendInsertOperation_for_only_identity_verification(StringBuilder stringBuilder)
=> AssertBaseline(
@"INSERT INTO ""Ducks"" (""Name"", ""Quacks"", ""ConcurrencyToken"")
VALUES (@p0, @p1, @p2) RETURNING ""Id"";
VALUES (@p0, @p1, @p2)
RETURNING ""Id"";
",
stringBuilder.ToString());

protected override void AppendInsertOperation_for_all_store_generated_columns_verification(StringBuilder stringBuilder)
=> AssertBaseline(
@"INSERT INTO ""Ducks""
DEFAULT VALUES RETURNING ""Id"", ""Computed"";
DEFAULT VALUES
RETURNING ""Id"", ""Computed"";
",
stringBuilder.ToString());

protected override void AppendInsertOperation_for_only_single_identity_columns_verification(
StringBuilder stringBuilder)
=> AssertBaseline(
@"INSERT INTO ""Ducks""
DEFAULT VALUES RETURNING ""Id"";
DEFAULT VALUES
RETURNING ""Id"";
",
stringBuilder.ToString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public override async Task Add_with_generated_values(bool async)
@"@p0='1000'
INSERT INTO ""WithSomeDatabaseGenerated"" (""Data2"")
VALUES (@p0) RETURNING ""Id"", ""Data1"";");
VALUES (@p0)
RETURNING ""Id"", ""Data1"";");
}

public override async Task Add_with_no_generated_values(bool async)
Expand All @@ -54,7 +55,8 @@ public override async Task Add_with_all_generated_values(bool async)

AssertSql(
@"INSERT INTO ""WithAllDatabaseGenerated""
DEFAULT VALUES RETURNING ""Id"", ""Data1"", ""Data2"";");
DEFAULT VALUES
RETURNING ""Id"", ""Data1"", ""Data2"";");
}

public override async Task Modify_with_generated_values(bool async)
Expand Down Expand Up @@ -110,12 +112,14 @@ public override async Task Add_Add_with_same_entity_type_and_generated_values(bo
@"@p0='1000'
INSERT INTO ""WithSomeDatabaseGenerated"" (""Data2"")
VALUES (@p0) RETURNING ""Id"", ""Data1"";",
VALUES (@p0)
RETURNING ""Id"", ""Data1"";",
//
@"@p0='1001'
INSERT INTO ""WithSomeDatabaseGenerated"" (""Data2"")
VALUES (@p0) RETURNING ""Id"", ""Data1"";");
VALUES (@p0)
RETURNING ""Id"", ""Data1"";");
}

public override async Task Add_Add_with_same_entity_type_and_no_generated_values(bool async)
Expand Down Expand Up @@ -144,10 +148,12 @@ public override async Task Add_Add_with_same_entity_type_and_all_generated_value

AssertSql(
@"INSERT INTO ""WithAllDatabaseGenerated""
DEFAULT VALUES RETURNING ""Id"", ""Data1"", ""Data2"";",
DEFAULT VALUES
RETURNING ""Id"", ""Data1"", ""Data2"";",
//
@"INSERT INTO ""WithAllDatabaseGenerated""
DEFAULT VALUES RETURNING ""Id"", ""Data1"", ""Data2"";");
DEFAULT VALUES
RETURNING ""Id"", ""Data1"", ""Data2"";");
}

public override async Task Modify_Modify_with_same_entity_type_and_generated_values(bool async)
Expand Down Expand Up @@ -226,12 +232,14 @@ public override async Task Add_Add_with_different_entity_types_and_generated_val
@"@p0='1000'
INSERT INTO ""WithSomeDatabaseGenerated"" (""Data2"")
VALUES (@p0) RETURNING ""Id"", ""Data1"";",
VALUES (@p0)
RETURNING ""Id"", ""Data1"";",
//
@"@p0='1001'
INSERT INTO ""WithSomeDatabaseGenerated2"" (""Data2"")
VALUES (@p0) RETURNING ""Id"", ""Data1"";");
VALUES (@p0)
RETURNING ""Id"", ""Data1"";");
}

public override async Task Add_Add_with_different_entity_types_and_no_generated_values(bool async)
Expand Down Expand Up @@ -260,10 +268,12 @@ public override async Task Add_Add_with_different_entity_types_and_all_generated

AssertSql(
@"INSERT INTO ""WithAllDatabaseGenerated""
DEFAULT VALUES RETURNING ""Id"", ""Data1"", ""Data2"";",
DEFAULT VALUES
RETURNING ""Id"", ""Data1"", ""Data2"";",
//
@"INSERT INTO ""WithAllDatabaseGenerated2""
DEFAULT VALUES RETURNING ""Id"", ""Data1"", ""Data2"";");
DEFAULT VALUES
RETURNING ""Id"", ""Data1"", ""Data2"";");
}

public override async Task Modify_Modify_with_different_entity_types_and_generated_values(bool async)
Expand Down

0 comments on commit f81b86d

Please sign in to comment.