diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs b/src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs
index 629792b9af..6d8a39c288 100644
--- a/src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs
+++ b/src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs
@@ -41,14 +41,14 @@ public class NpgsqlNodaTimeTypeMappingSourcePlugin : IRelationalTypeMappingSourc
///
/// Constructs an instance of the class.
///
- public NpgsqlNodaTimeTypeMappingSourcePlugin()
+ public NpgsqlNodaTimeTypeMappingSourcePlugin([NotNull] ISqlGenerationHelper sqlGenerationHelper)
{
- _timestampLocalDateTimeRange = new NpgsqlRangeTypeMapping("tsrange", typeof(NpgsqlRange), _timestampLocalDateTime);
- _timestampInstantRange = new NpgsqlRangeTypeMapping("tsrange", typeof(NpgsqlRange), _timestampInstant);
- _timestamptzInstantRange = new NpgsqlRangeTypeMapping("tstzrange", typeof(NpgsqlRange), _timestamptzInstant);
- _timestamptzZonedDateTimeRange = new NpgsqlRangeTypeMapping("tstzrange", typeof(NpgsqlRange), _timestamptzZonedDateTime);
- _timestamptzOffsetDateTimeRange = new NpgsqlRangeTypeMapping("tstzrange", typeof(NpgsqlRange), _timestamptzOffsetDateTime);
- _dateRange = new NpgsqlRangeTypeMapping("daterange", typeof(NpgsqlRange), _date);
+ _timestampLocalDateTimeRange = new NpgsqlRangeTypeMapping("tsrange", typeof(NpgsqlRange), _timestampLocalDateTime, sqlGenerationHelper);
+ _timestampInstantRange = new NpgsqlRangeTypeMapping("tsrange", typeof(NpgsqlRange), _timestampInstant, sqlGenerationHelper);
+ _timestamptzInstantRange = new NpgsqlRangeTypeMapping("tstzrange", typeof(NpgsqlRange), _timestamptzInstant, sqlGenerationHelper);
+ _timestamptzZonedDateTimeRange = new NpgsqlRangeTypeMapping("tstzrange", typeof(NpgsqlRange), _timestamptzZonedDateTime, sqlGenerationHelper);
+ _timestamptzOffsetDateTimeRange = new NpgsqlRangeTypeMapping("tstzrange", typeof(NpgsqlRange), _timestamptzOffsetDateTime, sqlGenerationHelper);
+ _dateRange = new NpgsqlRangeTypeMapping("daterange", typeof(NpgsqlRange), _date, sqlGenerationHelper);
var storeTypeMappings = new Dictionary(StringComparer.OrdinalIgnoreCase)
{
diff --git a/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs b/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs
index 472ad7c791..a73cd17baa 100644
--- a/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs
+++ b/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs
@@ -94,24 +94,28 @@ public override bool ApplyServices(IServiceCollection services)
/// Returns a copy of the current instance configured with the specified range mapping.
///
[NotNull]
- public virtual NpgsqlOptionsExtension WithUserRangeDefinition(string rangeName, string subtypeName)
- {
- var clone = (NpgsqlOptionsExtension)Clone();
-
- clone._userRangeDefinitions.Add(new UserRangeDefinition(rangeName, typeof(TSubtype), subtypeName));
-
- return clone;
- }
+ public virtual NpgsqlOptionsExtension WithUserRangeDefinition(
+ [NotNull] string rangeName,
+ [CanBeNull] string schemaName = null,
+ [CanBeNull] string subtypeName = null)
+ => WithUserRangeDefinition(rangeName, schemaName, typeof(TSubtype), subtypeName);
///
/// Returns a copy of the current instance configured with the specified range mapping.
///
[NotNull]
- public virtual NpgsqlOptionsExtension WithUserRangeDefinition(string rangeName, Type subtypeClrType, string subtypeName)
+ public virtual NpgsqlOptionsExtension WithUserRangeDefinition(
+ [NotNull] string rangeName,
+ [CanBeNull] string schemaName,
+ [NotNull] Type subtypeClrType,
+ [CanBeNull] string subtypeName)
{
+ Check.NotEmpty(rangeName, nameof(rangeName));
+ Check.NotNull(subtypeClrType, nameof(subtypeClrType));
+
var clone = (NpgsqlOptionsExtension)Clone();
- clone._userRangeDefinitions.Add(new UserRangeDefinition(rangeName, subtypeClrType, subtypeName));
+ clone._userRangeDefinitions.Add(new UserRangeDefinition(rangeName, schemaName, subtypeClrType, subtypeName));
return clone;
}
@@ -196,29 +200,52 @@ public virtual NpgsqlOptionsExtension WithRemoteCertificateValidationCallback([C
public class UserRangeDefinition
{
- /// The name of the PostgreSQL range type to be mapped.
+ ///
+ /// The name of the PostgreSQL range type to be mapped.
+ ///
+ [NotNull]
public string RangeName { get; }
+
+ ///
+ /// The PostgreSQL schema in which the range is defined.
+ ///
+ [CanBeNull]
+ public string SchemaName { get; }
+
///
/// The CLR type of the range's subtype (or element).
/// The actual mapped type will be an over this type.
///
+ [NotNull]
public Type SubtypeClrType { get; }
+
///
/// Optionally, the name of the range's PostgreSQL subtype (or element).
/// This is usually not needed - the subtype will be inferred based on .
///
+ [CanBeNull]
public string SubtypeName { get; }
- public UserRangeDefinition(string rangeName, Type subtypeClrType, string subtypeName)
+ public UserRangeDefinition(
+ [NotNull] string rangeName,
+ [CanBeNull] string schemaName,
+ [NotNull] Type subtypeClrType,
+ [CanBeNull] string subtypeName)
{
- RangeName = rangeName;
- SubtypeClrType = subtypeClrType;
+ RangeName = Check.NotEmpty(rangeName, nameof(rangeName));
+ SchemaName = schemaName;
+ SubtypeClrType = Check.NotNull(subtypeClrType, nameof(subtypeClrType));
SubtypeName = subtypeName;
}
- public void Deconstruct(out string rangeName, out Type subtypeClrType, out string subtypeName)
+ public void Deconstruct(
+ [NotNull] out string rangeName,
+ [CanBeNull] out string schemaName,
+ [NotNull] out Type subtypeClrType,
+ [CanBeNull] out string subtypeName)
{
rangeName = RangeName;
+ schemaName = SchemaName;
subtypeClrType = SubtypeClrType;
subtypeName = SubtypeName;
}
diff --git a/src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs b/src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs
index 96402428a8..f46dd0e50f 100644
--- a/src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs
+++ b/src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs
@@ -45,6 +45,7 @@ public virtual void SetPostgresVersion([CanBeNull] Version postgresVersion)
/// The actual mapped type will be an over this type.
///
/// The name of the PostgreSQL range type to be mapped.
+ /// The name of the PostgreSQL schema in which the range is defined.
///
/// Optionally, the name of the range's PostgreSQL subtype (or element).
/// This is usually not needed - the subtype will be inferred based on .
@@ -53,13 +54,14 @@ public virtual void SetPostgresVersion([CanBeNull] Version postgresVersion)
/// To map a range of PostgreSQL real, use the following:
/// NpgsqlTypeMappingSource.MapRange{float}("floatrange");
///
- public virtual void MapRange([NotNull] string rangeName, string subtypeName = null)
- => WithOption(e => e.WithUserRangeDefinition(rangeName, typeof(TSubtype), subtypeName));
+ public virtual void MapRange([NotNull] string rangeName, string schemaName = null, string subtypeName = null)
+ => MapRange(rangeName, typeof(TSubtype), schemaName, subtypeName);
///
/// Maps a user-defined PostgreSQL range type for use.
///
/// The name of the PostgreSQL range type to be mapped.
+ /// The name of the PostgreSQL schema in which the range is defined.
///
/// The CLR type of the range's subtype (or element).
/// The actual mapped type will be an over this type.
@@ -72,8 +74,8 @@ public virtual void MapRange([NotNull] string rangeName, string subtyp
/// To map a range of PostgreSQL real, use the following:
/// NpgsqlTypeMappingSource.MapRange("floatrange", typeof(float));
///
- public virtual void MapRange([NotNull] string rangeName, [NotNull] Type subtypeClrType, string subtypeName = null)
- => WithOption(e => e.WithUserRangeDefinition(rangeName, subtypeClrType, subtypeName));
+ public virtual void MapRange([NotNull] string rangeName, [NotNull] Type subtypeClrType, string schemaName = null, string subtypeName = null)
+ => WithOption(e => e.WithUserRangeDefinition(rangeName, schemaName, subtypeClrType, subtypeName));
///
/// Appends NULLS FIRST to all ORDER BY clauses. This is important for the tests which were written
diff --git a/src/EFCore.PG/Metadata/PostgresRange.cs b/src/EFCore.PG/Metadata/PostgresRange.cs
index ab233ab399..23a1671abe 100644
--- a/src/EFCore.PG/Metadata/PostgresRange.cs
+++ b/src/EFCore.PG/Metadata/PostgresRange.cs
@@ -33,7 +33,7 @@ public static PostgresRange GetOrAddPostgresRange(
if (FindPostgresRange(annotatable, schema, name) is PostgresRange rangeType)
return rangeType;
- rangeType = new PostgresRange(annotatable, BuildAnnotationName(schema, name));
+ rangeType = new PostgresRange(annotatable, BuildAnnotationName(annotatable, schema, name));
rangeType.SetData(subtype, canonicalFunction, subtypeOpClass, collation, subtypeDiff);
return rangeType;
}
@@ -47,14 +47,22 @@ public static PostgresRange FindPostgresRange(
Check.NotNull(annotatable, nameof(annotatable));
Check.NotEmpty(name, nameof(name));
- var annotationName = BuildAnnotationName(schema, name);
+ var annotationName = BuildAnnotationName(annotatable, schema, name);
return annotatable[annotationName] == null ? null : new PostgresRange(annotatable, annotationName);
}
[NotNull]
- static string BuildAnnotationName(string schema, string name)
- => NpgsqlAnnotationNames.RangePrefix + (schema == null ? name : schema + '.' + name);
+ static string BuildAnnotationName(IAnnotatable annotatable, string schema, string name)
+ {
+ if (!string.IsNullOrEmpty(schema))
+ return $"{NpgsqlAnnotationNames.RangePrefix}{schema}.{name}";
+
+ if (annotatable[RelationalAnnotationNames.DefaultSchema] is string defaultSchema && !string.IsNullOrEmpty(defaultSchema))
+ return $"{NpgsqlAnnotationNames.RangePrefix}{defaultSchema}.{name}";
+
+ return $"{NpgsqlAnnotationNames.RangePrefix}{name}";
+ }
[NotNull]
public static IEnumerable GetPostgresRanges([NotNull] IAnnotatable annotatable)
@@ -66,8 +74,8 @@ public static IEnumerable GetPostgresRanges([NotNull] IAnnotatabl
[NotNull]
public Annotatable Annotatable => (Annotatable)_annotatable;
- [NotNull]
- public string Schema => GetData().Schema;
+ [CanBeNull]
+ public string Schema => GetData().Schema ?? (string)_annotatable[RelationalAnnotationNames.DefaultSchema];
[NotNull]
public string Name => GetData().Name;
diff --git a/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs b/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs
index efef990d25..08e71357ae 100644
--- a/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs
+++ b/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs
@@ -658,6 +658,10 @@ protected override void Generate(
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
+ // Alter operations may not have a default schema attached. If not, try to attach one for schema-qualified types.
+ if (operation[RelationalAnnotationNames.DefaultSchema] == null)
+ operation[RelationalAnnotationNames.DefaultSchema] = model[RelationalAnnotationNames.DefaultSchema];
+
GenerateEnumStatements(operation, model, builder);
GenerateRangeStatements(operation, model, builder);
diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlRangeTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlRangeTypeMapping.cs
index e67d3dc565..229b537eed 100644
--- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlRangeTypeMapping.cs
+++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlRangeTypeMapping.cs
@@ -10,21 +10,43 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping
{
public class NpgsqlRangeTypeMapping : NpgsqlTypeMapping
{
+ [NotNull] readonly ISqlGenerationHelper _sqlGenerationHelper;
+
public RelationalTypeMapping SubtypeMapping { get; }
public NpgsqlRangeTypeMapping(
[NotNull] string storeType,
[NotNull] Type clrType,
- [NotNull] RelationalTypeMapping subtypeMapping)
- : base(storeType, clrType, GenerateNpgsqlDbType(subtypeMapping))
- => SubtypeMapping = subtypeMapping;
+ [NotNull] RelationalTypeMapping subtypeMapping,
+ [NotNull] ISqlGenerationHelper sqlGenerationHelper)
+ : this(storeType, null, clrType, subtypeMapping, sqlGenerationHelper) {}
- protected NpgsqlRangeTypeMapping(RelationalTypeMappingParameters parameters, NpgsqlDbType npgsqlDbType)
- : base(parameters, npgsqlDbType) { }
+ public NpgsqlRangeTypeMapping(
+ [NotNull] string storeType,
+ [CanBeNull] string storeTypeSchema,
+ [NotNull] Type clrType,
+ [NotNull] RelationalTypeMapping subtypeMapping,
+ [NotNull] ISqlGenerationHelper sqlGenerationHelper)
+ : base(sqlGenerationHelper.DelimitIdentifier(storeType, storeTypeSchema), clrType, GenerateNpgsqlDbType(subtypeMapping))
+ {
+ SubtypeMapping = subtypeMapping;
+ _sqlGenerationHelper = sqlGenerationHelper;
+ }
+
+ protected NpgsqlRangeTypeMapping(
+ RelationalTypeMappingParameters parameters,
+ NpgsqlDbType npgsqlDbType,
+ [NotNull] RelationalTypeMapping subtypeMapping,
+ [NotNull] ISqlGenerationHelper sqlGenerationHelper)
+ : base(parameters, npgsqlDbType)
+ {
+ SubtypeMapping = subtypeMapping;
+ _sqlGenerationHelper = sqlGenerationHelper;
+ }
[NotNull]
protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
- => new NpgsqlRangeTypeMapping(parameters, NpgsqlDbType);
+ => new NpgsqlRangeTypeMapping(parameters, NpgsqlDbType, SubtypeMapping, _sqlGenerationHelper);
protected override string GenerateNonNullSqlLiteral(object value)
{
diff --git a/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs b/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
index 7275a697a3..dd713f72f0 100644
--- a/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
+++ b/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
@@ -12,6 +12,7 @@
using Microsoft.EntityFrameworkCore.Storage;
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Utilities;
using Npgsql.TypeHandlers;
using NpgsqlTypes;
@@ -19,6 +20,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal
{
public class NpgsqlTypeMappingSource : RelationalTypeMappingSource
{
+ [NotNull] readonly ISqlGenerationHelper _sqlGenerationHelper;
+
public ConcurrentDictionary StoreTypeMappings { get; }
public ConcurrentDictionary ClrTypeMappings { get; }
@@ -105,16 +108,19 @@ public class NpgsqlTypeMappingSource : RelationalTypeMappingSource
public NpgsqlTypeMappingSource([NotNull] TypeMappingSourceDependencies dependencies,
[NotNull] RelationalTypeMappingSourceDependencies relationalDependencies,
+ [NotNull] ISqlGenerationHelper sqlGenerationHelper,
[CanBeNull] INpgsqlOptions npgsqlOptions=null)
: base(dependencies, relationalDependencies)
{
+ _sqlGenerationHelper = Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));
+
// Initialize some mappings which depend on other mappings
- _int4range = new NpgsqlRangeTypeMapping("int4range", typeof(NpgsqlRange), _int4);
- _int8range = new NpgsqlRangeTypeMapping("int8range", typeof(NpgsqlRange), _int8);
- _numrange = new NpgsqlRangeTypeMapping("numrange", typeof(NpgsqlRange), _numeric);
- _tsrange = new NpgsqlRangeTypeMapping("tsrange", typeof(NpgsqlRange), _timestamp);
- _tstzrange = new NpgsqlRangeTypeMapping("tstzrange", typeof(NpgsqlRange), _timestamptz);
- _daterange = new NpgsqlRangeTypeMapping("daterange", typeof(NpgsqlRange), _timestamptz);
+ _int4range = new NpgsqlRangeTypeMapping("int4range", typeof(NpgsqlRange), _int4, sqlGenerationHelper);
+ _int8range = new NpgsqlRangeTypeMapping("int8range", typeof(NpgsqlRange), _int8, sqlGenerationHelper);
+ _numrange = new NpgsqlRangeTypeMapping("numrange", typeof(NpgsqlRange), _numeric, sqlGenerationHelper);
+ _tsrange = new NpgsqlRangeTypeMapping("tsrange", typeof(NpgsqlRange), _timestamp, sqlGenerationHelper);
+ _tstzrange = new NpgsqlRangeTypeMapping("tstzrange", typeof(NpgsqlRange), _timestamptz, sqlGenerationHelper);
+ _daterange = new NpgsqlRangeTypeMapping("daterange", typeof(NpgsqlRange), _timestamptz, sqlGenerationHelper);
// Note that PostgreSQL has aliases to some built-in type name aliases (e.g. int4 for integer),
// these are mapped as well.
@@ -485,9 +491,9 @@ protected virtual RelationalTypeMapping FindUserRangeMapping(in RelationalTypeMa
// Finally, construct a range mapping and add it to our lookup dictionaries - next time it will be found as
// an existing mapping
- var rangeMapping = new NpgsqlRangeTypeMapping(rangeDefinition.RangeName, rangeClrType, subtypeMapping);
- StoreTypeMappings[rangeDefinition.RangeName] = new RelationalTypeMapping[] { rangeMapping };
- ClrTypeMappings[rangeClrType] = rangeMapping;
+ var rangeMapping = new NpgsqlRangeTypeMapping(rangeDefinition.RangeName, rangeDefinition.SchemaName, rangeClrType, subtypeMapping, _sqlGenerationHelper);
+ StoreTypeMappings[rangeMapping.StoreType] = new RelationalTypeMapping[] { rangeMapping };
+ ClrTypeMappings[rangeMapping.ClrType] = rangeMapping;
return rangeMapping;
}
diff --git a/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs
index 988d6fb696..f525ae8ad5 100644
--- a/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs
+++ b/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs
@@ -492,6 +492,18 @@ public void UserDefined()
}
}
+ [Fact]
+ public void UserDefinedSchemaQualified()
+ {
+ using (RangeContext context = Fixture.CreateContext())
+ {
+ var e = context.RangeTestEntities.Single(x => x.SchemaRange == NpgsqlRange.Parse("(0,10)"));
+ AssertContainsSql("WHERE x.\"SchemaRange\" = @__Parse_0");
+ Assert.Equal(e.SchemaRange.LowerBound, 0);
+ Assert.Equal(e.SchemaRange.UpperBound, 10);
+ }
+ }
+
#endregion
#region Functions
@@ -675,6 +687,7 @@ public RangeQueryNpgsqlFixture()
.UseNpgsql(_testStore.ConnectionString, b =>
{
b.MapRange("floatrange", typeof(float));
+ b.MapRange("Schema_Range", "test");
b.ApplyConfiguration();
})
.UseInternalServiceProvider(
@@ -694,7 +707,8 @@ public RangeQueryNpgsqlFixture()
Id = 1,
// (0, 10)
Range = new NpgsqlRange(0, false, false, 10, false, false),
- FloatRange = new NpgsqlRange(0, false, false, 10, false, false)
+ FloatRange = new NpgsqlRange(0, false, false, 10, false, false),
+ SchemaRange = new NpgsqlRange(0, false, false, 10, false, false)
},
new RangeTestEntity
{
@@ -760,6 +774,7 @@ public class RangeTestEntity
public int Id { get; set; }
public NpgsqlRange Range { get; set; }
public NpgsqlRange FloatRange { get; set; }
+ public NpgsqlRange SchemaRange { get; set; }
}
///
@@ -782,7 +797,8 @@ public RangeContext(DbContextOptions options) : base(options) {}
///
protected override void OnModelCreating(ModelBuilder builder)
- => builder.ForNpgsqlHasRange("floatrange", "real");
+ => builder.ForNpgsqlHasRange("floatrange", "real")
+ .ForNpgsqlHasRange("test", "Schema_Range", "double precision");
}
#endregion
diff --git a/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs b/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs
index 29cc68f90e..9d4806c891 100644
--- a/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs
+++ b/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs
@@ -1711,6 +1711,7 @@ line line
Array.Empty()
),
new RelationalTypeMappingSourceDependencies(Array.Empty()),
+ new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
options
);
diff --git a/test/EFCore.PG.Plugins.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs b/test/EFCore.PG.Plugins.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs
index 92265127ed..0ca9ef99b4 100644
--- a/test/EFCore.PG.Plugins.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs
+++ b/test/EFCore.PG.Plugins.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs
@@ -118,7 +118,8 @@ public void GenerateSqlLiteral_returns_period_literal()
#region Support
- static readonly IRelationalTypeMappingSourcePlugin Mapper = new NpgsqlNodaTimeTypeMappingSourcePlugin();
+ static readonly IRelationalTypeMappingSourcePlugin Mapper =
+ new NpgsqlNodaTimeTypeMappingSourcePlugin(new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()));
static RelationalTypeMapping GetMapping(string storeType)
=> Mapper.FindMapping(new RelationalTypeMappingInfo(storeType));
diff --git a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs
index 1c1be96ec6..06c01e181c 100644
--- a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs
+++ b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs
@@ -1,5 +1,4 @@
using System;
-using System.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@@ -63,8 +62,8 @@ public void Unknown_StoreType_with_known_ClrType()
public NpgsqlTypeMappingSourceTest()
{
var builder = new DbContextOptionsBuilder();
- new NpgsqlDbContextOptionsBuilder(builder).MapRange("floatrange", typeof(float));
- new NpgsqlDbContextOptionsBuilder(builder).MapRange("dummyrange", typeof(DummyType), "dummy");
+ new NpgsqlDbContextOptionsBuilder(builder).MapRange("floatrange");
+ new NpgsqlDbContextOptionsBuilder(builder).MapRange("dummyrange", subtypeName: "dummy");
var options = new NpgsqlOptions();
options.Initialize(builder.Options);
@@ -74,6 +73,7 @@ public NpgsqlTypeMappingSourceTest()
Array.Empty()),
new RelationalTypeMappingSourceDependencies(
new[] { new DummyTypeMappingSourcePlugin() }),
+ new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
options);
}
diff --git a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs
index e4e523c8b8..dfafd779bd 100644
--- a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs
+++ b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs
@@ -432,6 +432,7 @@ public void GenerateSqlLiteral_returns_ranking_normalization_literal() => Assert
Array.Empty()
),
new RelationalTypeMappingSourceDependencies(Array.Empty()),
+ new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
new NpgsqlOptions()
);
diff --git a/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchFactoryTest.cs b/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchFactoryTest.cs
index 88c0639546..2584dfc54b 100644
--- a/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchFactoryTest.cs
+++ b/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchFactoryTest.cs
@@ -27,6 +27,7 @@ public void Uses_MaxBatchSize_specified_in_NpgsqlOptionsExtension()
Array.Empty()
),
new RelationalTypeMappingSourceDependencies(Array.Empty()),
+ new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
new NpgsqlOptions()
);
var factory = new NpgsqlModificationCommandBatchFactory(
@@ -63,6 +64,7 @@ public void MaxBatchSize_is_optional()
Array.Empty()
),
new RelationalTypeMappingSourceDependencies(Array.Empty()),
+ new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
new NpgsqlOptions()
);
var factory = new NpgsqlModificationCommandBatchFactory(
diff --git a/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchTest.cs b/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchTest.cs
index eb68004c89..630d7c83a5 100644
--- a/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchTest.cs
+++ b/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchTest.cs
@@ -24,6 +24,7 @@ public void AddCommand_returns_false_when_max_batch_size_is_reached()
Array.Empty()
),
new RelationalTypeMappingSourceDependencies(Array.Empty()),
+ new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
new NpgsqlOptions()
);