Fixes tests, adds notes

This commit is contained in:
Shannon
2019-11-19 15:38:06 +11:00
parent dbd76a903a
commit 0137996815
4 changed files with 40 additions and 0 deletions

View File

@@ -52,6 +52,7 @@ namespace Umbraco.Core.Persistence.Mappers
return mappedName;
}
// fixme: TSource is used for nothing
protected void DefineMap<TSource, TTarget>(string sourceName, string targetName)
{
if (_sqlSyntax == null)

View File

@@ -35,6 +35,7 @@ namespace Umbraco.Core.Persistence.Mappers
Add<AuditItemMapper>();
Add<ContentMapper>();
Add<ContentTypeMapper>();
Add<SimpleContentTypeMapper>();
Add<DataTypeMapper>();
Add<DictionaryMapper>();
Add<DictionaryTranslationMapper>();

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Concurrent;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Dtos;
namespace Umbraco.Core.Persistence.Mappers
{
// TODO: This mapper is actually very useless because the only time it would ever be used is when trying to generate a strongly typed query
// on an IContentBase object which is what exposes ISimpleContentType, however the queries that we execute in the content repositories don't actually
// join on the content type table. The content type data is resolved outside of the query so the end result of the query that is generated by using
// this mapper will either fail or the syntax will target umbracoNode which will be filtering on the actual content NOT the content type.
// I'm leaving this here purely because the ExpressionTests rely on this which is fine for testing that the expressions work, but note that this
// resulting query will not.
[MapperFor(typeof(ISimpleContentType))]
[MapperFor(typeof(SimpleContentType))]
public sealed class SimpleContentTypeMapper : BaseMapper
{
public SimpleContentTypeMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
: base(sqlContext, maps)
{ }
protected override void DefineMaps()
{
// There is no reason for using ContentType here instead of SimpleContentType, in fact the underlying DefineMap call does nothing with the first type parameter
DefineMap<ContentType, NodeDto>(nameof(ContentType.Id), nameof(NodeDto.NodeId));
DefineMap<ContentType, NodeDto>(nameof(ContentType.Key), nameof(NodeDto.UniqueId));
DefineMap<ContentType, NodeDto>(nameof(ContentType.Name), nameof(NodeDto.Text));
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Alias), nameof(ContentTypeDto.Alias));
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.Icon), nameof(ContentTypeDto.Icon));
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.IsContainer), nameof(ContentTypeDto.IsContainer));
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.AllowedAsRoot), nameof(ContentTypeDto.AllowAtRoot));
DefineMap<ContentType, ContentTypeDto>(nameof(ContentType.IsElement), nameof(ContentTypeDto.IsElement));
}
}
}

View File

@@ -217,6 +217,7 @@
<Compile Include="Models\PublishedContent\VariationContextAccessorExtensions.cs" />
<Compile Include="Models\Template.cs" />
<Compile Include="Models\TemplateOnDisk.cs" />
<Compile Include="Persistence\Mappers\SimpleContentTypeMapper.cs" />
<Compile Include="PropertyEditors\Validators\DelimitedValueValidator.cs" />
<Compile Include="PropertyEditors\Validators\RegexValidator.cs" />
<Compile Include="PropertyEditors\Validators\RequiredValidator.cs" />