Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suffix original value sproc parameters by default #28860

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,26 @@ public override bool IsReadOnly
/// </summary>
public virtual string Name
{
get => _name ?? (ForRowsAffected
? "RowsAffected"
: GetProperty().GetDefaultColumnName(
((IReadOnlyStoredProcedure)StoredProcedure).GetStoreIdentifier()!.Value)!);
get
{
if (_name != null)
{
return _name;
}

if (ForRowsAffected)
{
return "RowsAffected";
}
else
{
var baseName = GetProperty().GetDefaultColumnName(
((IReadOnlyStoredProcedure)StoredProcedure).GetStoreIdentifier()!.Value)!;
return ForOriginalValue ?? false
? Uniquifier.Truncate(baseName + "_Original", GetProperty().DeclaringEntityType.Model.GetMaxIdentifierLength())
AndriySvyryd marked this conversation as resolved.
Show resolved Hide resolved
: baseName;
}
}
set => SetName(value, ConfigurationSource.Explicit);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ public virtual void Sproc_overrides_update_when_renamed_in_TPH()
s => s.HasAnnotation("foo", "bar3")
.HasParameter(b => b.Id, p => p.HasName("DeleteId"))
.HasRowsAffectedResultColumn()
.HasParameter("RowVersion")
.HasOriginalValueParameter("RowVersion"));

modelBuilder.Entity<SpecialBookLabel>()
Expand Down Expand Up @@ -454,6 +455,7 @@ public virtual void Sproc_overrides_update_when_renamed_in_TPH()
Assert.Equal("Update", updateSproc.Name);
Assert.Equal("dbo", updateSproc.Schema);
Assert.Equal(new[] { "Id", "BookId", null, "RowVersion", "RowVersion" }, updateSproc.Parameters.Select(p => p.PropertyName));
Assert.Equal(new[] { "UpdateId", "BookId", "RowsAffected", "OriginalRowVersion", "RowVersion" }, updateSproc.Parameters.Select(p => p.Name));
Assert.Empty(updateSproc.ResultColumns);
Assert.Equal("bar2", updateSproc["foo"]);
Assert.Same(bookLabel, updateSproc.EntityType);
Expand All @@ -480,7 +482,8 @@ public virtual void Sproc_overrides_update_when_renamed_in_TPH()
var deleteSproc = bookLabel.GetDeleteStoredProcedure()!;
Assert.Equal("BookLabel_Delete", deleteSproc.Name);
Assert.Equal("mySchema", deleteSproc.Schema);
Assert.Equal(new[] { "Id", "RowVersion" }, deleteSproc.Parameters.Select(p => p.PropertyName));
Assert.Equal(new[] { "Id", "RowVersion", "RowVersion" }, deleteSproc.Parameters.Select(p => p.PropertyName));
Assert.Equal(new[] { "DeleteId", "RowVersion", "RowVersion_Original" }, deleteSproc.Parameters.Select(p => p.Name));
Assert.Equal(new[] { "RowsAffected" }, deleteSproc.ResultColumns.Select(p => p.Name));
Assert.Equal("bar3", deleteSproc["foo"]);
Assert.Same(bookLabel, deleteSproc.EntityType);
Expand Down