ensures the unique name check is not performed against itself
This commit is contained in:
@@ -1144,10 +1144,12 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
.InnerJoin<NodeDto>()
|
||||
.On<NodeDto, ContentVersionDto>(x => x.NodeId, x => x.NodeId)
|
||||
.Where<ContentVersionDto>(x => x.Current == SqlTemplate.Arg<bool>("current"))
|
||||
.Where<NodeDto>(x => x.NodeObjectType == SqlTemplate.Arg<Guid>("nodeObjectType") && x.ParentId == SqlTemplate.Arg<int>("parentId"))
|
||||
.Where<NodeDto>(x => x.NodeObjectType == SqlTemplate.Arg<Guid>("nodeObjectType")
|
||||
&& x.ParentId == SqlTemplate.Arg<int>("parentId")
|
||||
&& x.NodeId != SqlTemplate.Arg<int>($"{Constants.DatabaseSchema.Tables.Node}.id"))
|
||||
.OrderBy<ContentVersionCultureVariationDto>(x => x.LanguageId));
|
||||
|
||||
var sql = template.Sql(true, NodeObjectTypeId, content.ParentId);
|
||||
var sql = template.Sql(true, NodeObjectTypeId, content.ParentId, content.Id);
|
||||
var names = Database.Fetch<CultureNodeName>(sql)
|
||||
.GroupBy(x => x.LanguageId)
|
||||
.ToDictionary(x => x.Key, x => x);
|
||||
|
||||
@@ -2565,7 +2565,10 @@ namespace Umbraco.Tests.Services
|
||||
var child = new Content(null, content, contentType);
|
||||
child.SetName("child", langUk.IsoCode);
|
||||
contentService.Save(child);
|
||||
Assert.AreEqual("child" + (i == 0 ? "" : " (" + (i).ToString() + ")"), child.GetName(langUk.IsoCode));
|
||||
|
||||
//Save it again to ensure that the unique check is not performed again against it's own name
|
||||
contentService.Save(child);
|
||||
Assert.AreEqual("child" + (i == 0 ? "" : " (" + (i).ToString() + ")"), child.GetName(langUk.IsoCode));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user