ensures the unique name check is not performed against itself

This commit is contained in:
Shannon
2018-06-01 15:51:45 +10:00
parent b75cf3bc76
commit 3cfd9c5b00
2 changed files with 7 additions and 2 deletions

View File

@@ -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);

View File

@@ -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));
}
}