Skip to content
Permalink
Browse files

Removed unmapped composite support

  • Loading branch information...
YohDeadfall committed May 19, 2019
1 parent 054b4e4 commit 929fb41e17ea010fa6b770434e9e3e28bb45de91
@@ -248,7 +248,7 @@ void ColumnPostConfig(NpgsqlDbColumn column, int typeModifier)
{
column.IsLong = handler is ByteaHandler;

if (handler is IMappedCompositeHandler)
if (handler is ICompositeHandler)
column.UdtAssemblyQualifiedName = column.DataType.AssemblyQualifiedName;
}

@@ -11,7 +11,7 @@

namespace Npgsql.TypeHandlers.CompositeHandlers
{
class MappedCompositeHandler<T> : NpgsqlTypeHandler<T>, IMappedCompositeHandler
class CompositeHandler<T> : NpgsqlTypeHandler<T>, ICompositeHandler
where T : new()
{
static readonly Func<T> Constructor = Expression
@@ -24,7 +24,7 @@ class MappedCompositeHandler<T> : NpgsqlTypeHandler<T>, IMappedCompositeHandler

public Type CompositeType => typeof(T);

public MappedCompositeHandler(PostgresCompositeType postgresType, ConnectorTypeMapper typeMapper, INpgsqlNameTranslator nameTranslator)
public CompositeHandler(PostgresCompositeType postgresType, ConnectorTypeMapper typeMapper, INpgsqlNameTranslator nameTranslator)
: base(postgresType)
{
_typeMapper = typeMapper;
@@ -3,15 +3,15 @@

namespace Npgsql.TypeHandlers.CompositeHandlers
{
class MappedCompositeTypeHandlerFactory<T> : NpgsqlTypeHandlerFactory<T>, IMappedCompositeTypeHandlerFactory
class CompositeTypeHandlerFactory<T> : NpgsqlTypeHandlerFactory<T>, ICompositeTypeHandlerFactory
where T : new()
{
public INpgsqlNameTranslator NameTranslator { get; }

internal MappedCompositeTypeHandlerFactory(INpgsqlNameTranslator nameTranslator)
internal CompositeTypeHandlerFactory(INpgsqlNameTranslator nameTranslator)
=> NameTranslator = nameTranslator;

public override NpgsqlTypeHandler<T> Create(PostgresType pgType, NpgsqlConnection conn)
=> new MappedCompositeHandler<T>((PostgresCompositeType)pgType, conn.Connector!.TypeMapper, NameTranslator);
=> new CompositeHandler<T>((PostgresCompositeType)pgType, conn.Connector!.TypeMapper, NameTranslator);
}
}
@@ -2,7 +2,7 @@

namespace Npgsql.TypeHandlers.CompositeHandlers
{
interface IMappedCompositeHandler
interface ICompositeHandler
{
/// <summary>
/// The CLR type mapped to the PostgreSQL composite type.
@@ -4,7 +4,7 @@ namespace Npgsql.TypeHandlers.CompositeHandlers
/// Interface implemented by all mapped composite handler factories.
/// Used to expose the name translator for those reflecting composite mappings (e.g. EF Core).
/// </summary>
public interface IMappedCompositeTypeHandlerFactory
public interface ICompositeTypeHandlerFactory
{
/// <summary>
/// The name translator used for this composite.

This file was deleted.

This file was deleted.

@@ -239,11 +239,6 @@ void BindTypes()
if (domain.Array != null)
BindType(baseTypeHandler.CreateArrayHandler(domain.Array), domain.Array);
}

// Composites
var dynamicCompositeFactory = new UnmappedCompositeTypeHandlerFactory(DefaultNameTranslator);
foreach (var compType in DatabaseInfo.CompositeTypes.Where(e => !_byOID.ContainsKey(e.OID)))
BindType(dynamicCompositeFactory.Create(compType, _connector.Connection!), compType);
}

void BindType(NpgsqlTypeMapping mapping, NpgsqlConnector connector, bool externalCall)
@@ -93,7 +93,7 @@ public INpgsqlTypeMapper MapComposite<T>(string? pgName = null, INpgsqlNameTrans
{
PgTypeName = pgName,
ClrTypes = new[] { typeof(T) },
TypeHandlerFactory = new MappedCompositeTypeHandlerFactory<T>(nameTranslator)
TypeHandlerFactory = new CompositeTypeHandlerFactory<T>(nameTranslator)
}.Build());
}

0 comments on commit 929fb41

Please sign in to comment.
You can’t perform that action at this time.