未验证 提交 9607bd1b 编写于 作者: S Shay Rojansky 提交者: GitHub

Bump dependencies (#1832)

EFCore -> 6.0.0-preview.5.21230.1 (67a5d1697131086b9984c457cec944e8f957f2d8)
MicrosoftExtensions -> 6.0.0-preview.5.21226.1
Npgsql -> 6.0.0-ci.20210502T183829
上级 aebc18ad
<Project>
<PropertyGroup>
<EFCoreVersion>6.0.0-preview.5.21219.5</EFCoreVersion>
<MicrosoftExtensionsVersion>6.0.0-preview.5.21218.1</MicrosoftExtensionsVersion>
<NpgsqlVersion>6.0.0-ci.20210418T145437</NpgsqlVersion>
<EFCoreVersion>6.0.0-preview.5.21230.1</EFCoreVersion>
<MicrosoftExtensionsVersion>6.0.0-preview.5.21226.1</MicrosoftExtensionsVersion>
<NpgsqlVersion>6.0.0-ci.20210502T183829</NpgsqlVersion>
</PropertyGroup>
<ItemGroup>
......
......@@ -232,7 +232,7 @@ public static NpgsqlValueGenerationStrategy GetValueGenerationStrategy(this IRea
if (property.ValueGenerated != ValueGenerated.OnAdd
|| property.IsForeignKey()
|| property.GetDefaultValue() != null
|| property.TryGetDefaultValue(out _)
|| property.GetDefaultValueSql() != null
|| property.GetComputedColumnSql() != null)
{
......@@ -281,7 +281,7 @@ valueGenerationStrategy switch
if (property.ValueGenerated != ValueGenerated.OnAdd
|| property.GetContainingForeignKeys().Any(fk => !fk.IsBaseLinking())
|| property.GetDefaultValue() != null
|| property.TryGetDefaultValue(storeObject, out _)
|| property.GetDefaultValueSql() != null
|| property.GetComputedColumnSql() != null)
{
......
......@@ -106,7 +106,7 @@ protected override void Validate(IConventionProperty property, in StoreObjectIde
return;
}
if (property.GetDefaultValue() != null)
if (property.TryGetDefaultValue(storeObject, out _))
{
throw new InvalidOperationException(
RelationalStrings.ConflictingColumnServerGeneration(
......
......@@ -86,15 +86,17 @@ public virtual void ProcessModelInitialized(IConventionModelBuilder modelBuilder
}
}
static bool IsStrategyNoneNeeded(IReadOnlyProperty property, StoreObjectIdentifier storeObject)
bool IsStrategyNoneNeeded(IReadOnlyProperty property, StoreObjectIdentifier storeObject)
{
if (property.ValueGenerated == ValueGenerated.OnAdd
&& property.GetDefaultValue(storeObject) == null
&& !property.TryGetDefaultValue(storeObject, out _)
&& property.GetDefaultValueSql(storeObject) == null
&& property.GetComputedColumnSql(storeObject) == null
&& property.DeclaringEntityType.Model.GetValueGenerationStrategy() != NpgsqlValueGenerationStrategy.None)
{
var providerClrType = (property.GetValueConverter() ?? property.FindRelationalTypeMapping(storeObject)?.Converter)
var providerClrType = (property.GetValueConverter()
?? (property.FindRelationalTypeMapping(storeObject)
?? Dependencies.TypeMappingSource.FindMapping((IProperty)property))?.Converter)
?.ProviderClrType.UnwrapNullableType();
return providerClrType != null && (providerClrType.IsInteger());
......
......@@ -38,7 +38,7 @@ public TestSqlLoggerFactory TestSqlLoggerFactory
=> (TestSqlLoggerFactory)ListLoggerFactory;
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
=> builder.DisableConcurrencyDetection();
=> builder.EnableThreadSafetyChecks(enableChecks: false);
}
}
}
using System;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
using Xunit;
......@@ -17,6 +18,13 @@ public CustomConvertersNpgsqlTest(CustomConvertersNpgsqlFixture fixture)
// Disabled: PostgreSQL is case-sensitive
public override void Can_insert_and_read_back_with_case_insensitive_string_key() {}
public override void Value_conversion_on_enum_collection_contains()
{
Assert.Contains(
CoreStrings.TranslationFailed("").Substring(47),
Assert.Throws<InvalidOperationException>(() => base.Value_conversion_on_enum_collection_contains()).Message);
}
public class CustomConvertersNpgsqlFixture : CustomConvertersFixtureBase
{
public override bool StrictEquality => true;
......
......@@ -157,7 +157,9 @@ public override MigrationsContext CreateContext()
{
var options = AddOptions(
new DbContextOptionsBuilder()
.UseNpgsql(TestStore.ConnectionString, b => b.ApplyConfiguration().CommandTimeout(NpgsqlTestStore.CommandTimeout)))
.UseNpgsql(TestStore.ConnectionString, b => b.ApplyConfiguration()
.CommandTimeout(NpgsqlTestStore.CommandTimeout)
.ReverseNullOrdering()))
.UseInternalServiceProvider(ServiceProvider)
.Options;
return new MigrationsContext(options);
......
......@@ -691,7 +691,7 @@ public void Array_column_Contains_in_scalar_subquery(bool list)
SELECT s0.""NullableIntArray""
FROM ""SomeEntities"" AS s0
WHERE s.""Id"" = s0.""SomeContainerEntityId""
ORDER BY s0.""Id""
ORDER BY s0.""Id"" NULLS FIRST
LIMIT 1)::integer[])
LIMIT 2");
}
......
using Microsoft.EntityFrameworkCore.Query;
using Xunit.Abstractions;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class ComplexNavigationsCollectionsQueryNpgsqlTest : ComplexNavigationsCollectionsQueryRelationalTestBase<ComplexNavigationsQueryNpgsqlFixture>
{
public ComplexNavigationsCollectionsQueryNpgsqlTest(
ComplexNavigationsQueryNpgsqlFixture fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
}
using Microsoft.EntityFrameworkCore.Query;
using Xunit.Abstractions;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class ComplexNavigationsCollectionsSharedTypeQueryNpgsqlTest : ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase<
ComplexNavigationsSharedTypeQueryNpgsqlFixture>
{
public ComplexNavigationsCollectionsSharedTypeQueryNpgsqlTest(
ComplexNavigationsSharedTypeQueryNpgsqlFixture fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
}
using Microsoft.EntityFrameworkCore.Query;
using Xunit.Abstractions;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class ComplexNavigationsCollectionsSplitQueryNpgsqlTest : ComplexNavigationsCollectionsSplitQueryRelationalTestBase<ComplexNavigationsQueryNpgsqlFixture>
{
public ComplexNavigationsCollectionsSplitQueryNpgsqlTest(
ComplexNavigationsQueryNpgsqlFixture fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
}
using Microsoft.EntityFrameworkCore.Query;
using Xunit.Abstractions;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class ComplexNavigationsCollectionsSplitSharedTypeQueryNpgsqlTest : ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase<
ComplexNavigationsSharedTypeQueryNpgsqlFixture>
{
public ComplexNavigationsCollectionsSplitSharedTypeQueryNpgsqlTest(
ComplexNavigationsSharedTypeQueryNpgsqlFixture fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
}
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class ComplexNavigationsQueryNpgsqlFixture : ComplexNavigationsQueryRelationalFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
// public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
// {
// var optionsBuilder = base.AddOptions(builder);
// new NpgsqlDbContextOptionsBuilder(optionsBuilder).ReverseNullOrdering();
// return optionsBuilder;
// }
}
}
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
using Xunit;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
......@@ -21,13 +19,6 @@ public class ComplexNavigationsQueryNpgsqlFixture
: ComplexNavigationsQueryRelationalFixtureBase
{
protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance;
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
{
var optionsBuilder = base.AddOptions(builder);
new NpgsqlDbContextOptionsBuilder(optionsBuilder).ReverseNullOrdering();
return optionsBuilder;
}
}
}
}
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class ComplexNavigationsSharedTypeQueryNpgsqlFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
}
}
using System;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
using Xunit;
using Xunit.Abstractions;
......@@ -36,13 +32,6 @@ public class ComplexNavigationsSharedTypeQueryNpgsqlFixture : ComplexNavigations
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
{
var optionsBuilder = base.AddOptions(builder);
new NpgsqlDbContextOptionsBuilder(optionsBuilder).ReverseNullOrdering();
return optionsBuilder;
}
}
}
}
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class CompositeKeysQueryNpgsqlFixture : CompositeKeysQueryRelationalFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
}
}
using Microsoft.EntityFrameworkCore.Query;
using Xunit.Abstractions;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class CompositeKeysQueryNpgsqlTest : CompositeKeysQueryRelationalTestBase<CompositeKeysQueryNpgsqlFixture>
{
public CompositeKeysQueryNpgsqlTest(
CompositeKeysQueryNpgsqlFixture fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
}
using Microsoft.EntityFrameworkCore.Query;
using Xunit.Abstractions;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class CompositeKeysSplitQueryNpgsqlTest : CompositeKeysSplitQueryRelationalTestBase<CompositeKeysQueryNpgsqlFixture>
{
public CompositeKeysSplitQueryNpgsqlTest(
CompositeKeysQueryNpgsqlFixture fixture,
ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
}
}
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
......@@ -18,12 +17,5 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
modelBuilder.HasPostgresExtension("uuid-ossp");
//modelBuilder.Entity<Mission>().Ignore(m => m.Timeline);
}
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
{
var optionsBuilder = base.AddOptions(builder);
new NpgsqlDbContextOptionsBuilder(optionsBuilder).ReverseNullOrdering();
return optionsBuilder;
}
}
}
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
......@@ -9,12 +7,5 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
public class ManyToManyQueryNpgsqlFixture : ManyToManyQueryRelationalFixture
{
protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance;
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
{
var optionsBuilder = base.AddOptions(builder);
new NpgsqlDbContextOptionsBuilder(optionsBuilder).ReverseNullOrdering();
return optionsBuilder;
}
}
}
......@@ -19,9 +19,7 @@ public class NorthwindQueryNpgsqlFixture<TModelCustomizer> : NorthwindQueryRelat
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
{
var optionsBuilder = base.AddOptions(builder);
new NpgsqlDbContextOptionsBuilder(optionsBuilder)
.ReverseNullOrdering()
.SetPostgresVersion(TestEnvironment.PostgresVersion);
new NpgsqlDbContextOptionsBuilder(optionsBuilder).SetPostgresVersion(TestEnvironment.PostgresVersion);
return optionsBuilder;
}
......
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit.Abstractions;
......@@ -15,15 +11,7 @@ public class NorthwindSplitIncludeNoTrackingQueryNpgsqlTest : NorthwindSplitIncl
NorthwindQueryNpgsqlFixture<NoopModelCustomizer> fixture, ITestOutputHelper testOutputHelper)
: base(fixture)
{
//TestSqlLoggerFactory.CaptureOutput(testOutputHelper);
// TestSqlLoggerFactory.CaptureOutput(testOutputHelper);
}
public override Task Include_collection_with_last_no_orderby(bool async)
=> AssertTranslationFailedWithDetails(
() => AssertLast(
async,
ss => ss.Set<Customer>().Include(c => c.Orders),
entryCount: 8
), RelationalStrings.MissingOrderingInSelectExpression);
}
}
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Xunit.Abstractions;
......@@ -15,15 +11,7 @@ public class NorthwindSplitIncludeQueryNpgsqlTest : NorthwindSplitIncludeQueryTe
NorthwindQueryNpgsqlFixture<NoopModelCustomizer> fixture, ITestOutputHelper testOutputHelper)
: base(fixture)
{
//TestSqlLoggerFactory.CaptureOutput(testOutputHelper);
// TestSqlLoggerFactory.CaptureOutput(testOutputHelper);
}
public override Task Include_collection_with_last_no_orderby(bool async)
=> AssertTranslationFailedWithDetails(
() => AssertLast(
async,
ss => ss.Set<Customer>().Include(c => c.Orders),
entryCount: 8
), RelationalStrings.MissingOrderingInSelectExpression);
}
}
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
{
public class OwnedEntityQueryNpgsqlTest : OwnedEntityQueryRelationalTestBase
{
protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance;
}
}
......@@ -17,12 +17,5 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
modelBuilder.Entity<City>().Property(g => g.Location).HasColumnType("varchar(100)");
}
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
{
var optionsBuilder = base.AddOptions(builder);
new NpgsqlDbContextOptionsBuilder(optionsBuilder).ReverseNullOrdering();
return optionsBuilder;
}
}
}
......@@ -9,12 +9,5 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
public class TPTManyToManyQueryNpgsqlFixture : TPTManyToManyQueryRelationalFixture
{
protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance;
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
{
var optionsBuilder = base.AddOptions(builder);
new NpgsqlDbContextOptionsBuilder(optionsBuilder).ReverseNullOrdering();
return optionsBuilder;
}
}
}
......@@ -229,7 +229,7 @@ public override void Scalar_Nested_Function_Unwind_Client_Eval_Select_Static()
AssertSql(
@"SELECT c.""Id""
FROM ""Customers"" AS c
ORDER BY c.""Id""");
ORDER BY c.""Id"" NULLS FIRST");
}
[Fact]
......@@ -265,7 +265,7 @@ public override void Nullable_navigation_property_access_preserves_schema_for_sq
@"SELECT dbo.""IdentityString""(c.""FirstName"")
FROM ""Orders"" AS o
INNER JOIN ""Customers"" AS c ON o.""CustomerId"" = c.""Id""
ORDER BY o.""Id""
ORDER BY o.""Id"" NULLS FIRST
LIMIT 1");
}
......@@ -487,7 +487,7 @@ public override void Scalar_Nested_Function_Unwind_Client_Eval_Select_Instance()
AssertSql(
@"SELECT c.""Id""
FROM ""Customers"" AS c
ORDER BY c.""Id""");
ORDER BY c.""Id"" NULLS FIRST");
}
[Fact]
......
......@@ -101,7 +101,11 @@ protected override void Initialize(Func<DbContext> createContext, Action<DbConte
}
public override DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuilder builder)
=> builder.UseNpgsql(Connection, b => b.ApplyConfiguration().CommandTimeout(CommandTimeout));
=> builder.UseNpgsql(Connection, b => b.ApplyConfiguration()
.CommandTimeout(CommandTimeout)
// The tests are written with the assumption that NULLs are sorted first (SQL Server and .NET behavior), but PostgreSQL
// sorts NULLs last by default. This configures the provider to emit NULLS FIRST.
.ReverseNullOrdering());
private static string GetScratchDbName()
{
......
......@@ -222,8 +222,8 @@ private string PreExecution(IRelationalConnection connection)
return errorNumber;
}
public void PopulateFromTemplate(IRelationalCommand templateCommand)
=> _realRelationalCommand.PopulateFromTemplate(templateCommand);
public void PopulateFrom(IRelationalCommand command)
=> _realRelationalCommand.PopulateFrom(command);
}
}
}
......@@ -30,7 +30,9 @@ protected override DbContext CreateContextWithConnectionString()
new DbContextOptionsBuilder()
.UseNpgsql(
TestStore.ConnectionString,
b => b.ApplyConfiguration().ExecutionStrategy(c => new NpgsqlExecutionStrategy(c))))
b => b.ApplyConfiguration()
.ExecutionStrategy(c => new NpgsqlExecutionStrategy(c))
.ReverseNullOrdering()))
.UseInternalServiceProvider(Fixture.ServiceProvider);
return new DbContext(options.Options);
......
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
using Xunit;
namespace Npgsql.EntityFrameworkCore.PostgreSQL
{
public class ValueConvertersEndToEndNpgsqlTest
: ValueConvertersEndToEndTestBase<ValueConvertersEndToEndNpgsqlTest.ValueConvertersEndToEndSqlServerFixture>
{
public ValueConvertersEndToEndNpgsqlTest(ValueConvertersEndToEndSqlServerFixture fixture)
: base(fixture)
{
}
[ConditionalTheory]
[InlineData(nameof(ConvertingEntity.BoolAsChar), "character(1)", false)]
[InlineData(nameof(ConvertingEntity.BoolAsNullableChar), "character(1)", false)]
[InlineData(nameof(ConvertingEntity.BoolAsString), "character varying(3)", false)]
[InlineData(nameof(ConvertingEntity.BoolAsInt), "integer", false)]
[InlineData(nameof(ConvertingEntity.BoolAsNullableString), "character varying(3)", false)]
[InlineData(nameof(ConvertingEntity.BoolAsNullableInt), "integer", false)]
[InlineData(nameof(ConvertingEntity.IntAsLong), "bigint", false)]
[InlineData(nameof(ConvertingEntity.IntAsNullableLong), "bigint", false)]
[InlineData(nameof(ConvertingEntity.BytesAsString), "text", false)]
[InlineData(nameof(ConvertingEntity.BytesAsNullableString), "text", false)]
[InlineData(nameof(ConvertingEntity.CharAsString), "character varying(1)", false)]
[InlineData(nameof(ConvertingEntity.CharAsNullableString), "character varying(1)", false)]
[InlineData(nameof(ConvertingEntity.DateTimeOffsetToBinary), "bigint", false)]
[InlineData(nameof(ConvertingEntity.DateTimeOffsetToNullableBinary), "bigint", false)]
[InlineData(nameof(ConvertingEntity.DateTimeOffsetToString), "character varying(48)", false)]
[InlineData(nameof(ConvertingEntity.DateTimeOffsetToNullableString), "character varying(48)", false)]
[InlineData(nameof(ConvertingEntity.DateTimeToBinary), "bigint", false)]
[InlineData(nameof(ConvertingEntity.DateTimeToNullableBinary), "bigint", false)]
[InlineData(nameof(ConvertingEntity.DateTimeToString), "character varying(48)", false)]
[InlineData(nameof(ConvertingEntity.DateTimeToNullableString), "character varying(48)", false)]
[InlineData(nameof(ConvertingEntity.EnumToString), "text", false)]
[InlineData(nameof(ConvertingEntity.EnumToNullableString), "text", false)]
[InlineData(nameof(ConvertingEntity.EnumToNumber), "bigint", false)]
[InlineData(nameof(ConvertingEntity.EnumToNullableNumber), "bigint", false)]
[InlineData(nameof(ConvertingEntity.GuidToString), "character varying(36)", false)]
[InlineData(nameof(ConvertingEntity.GuidToNullableString), "character varying(36)", false)]
[InlineData(nameof(ConvertingEntity.GuidToBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.GuidToNullableBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.IPAddressToString), "character varying(45)", false)]
[InlineData(nameof(ConvertingEntity.IPAddressToNullableString), "character varying(45)", false)]
[InlineData(nameof(ConvertingEntity.IPAddressToBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.IPAddressToNullableBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.PhysicalAddressToString), "character varying(20)", false)]
[InlineData(nameof(ConvertingEntity.PhysicalAddressToNullableString), "character varying(20)", false)]
[InlineData(nameof(ConvertingEntity.PhysicalAddressToBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.PhysicalAddressToNullableBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.NumberToString), "character varying(64)", false)]
[InlineData(nameof(ConvertingEntity.NumberToNullableString), "character varying(64)", false)]
[InlineData(nameof(ConvertingEntity.NumberToBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.NumberToNullableBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.StringToBool), "boolean", false)]
[InlineData(nameof(ConvertingEntity.StringToNullableBool), "boolean", false)]
[InlineData(nameof(ConvertingEntity.StringToBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.StringToNullableBytes), "bytea", false)]
[InlineData(nameof(ConvertingEntity.StringToChar), "character(1)", false)]
[InlineData(nameof(ConvertingEntity.StringToNullableChar), "character(1)", false)]
[InlineData(nameof(ConvertingEntity.StringToDateTime), "timestamp without time zone", false)]
[InlineData(nameof(ConvertingEntity.StringToNullableDateTime), "timestamp without time zone", false)]
// [InlineData(nameof(ConvertingEntity.StringToDateTimeOffset), "timestamp with time zone", false)]
// [InlineData(nameof(ConvertingEntity.StringToNullableDateTimeOffset), "timestamp with time zone", false)]
[InlineData(nameof(ConvertingEntity.StringToEnum), "integer", false)]
[InlineData(nameof(ConvertingEntity.StringToNullableEnum), "integer", false)]
[InlineData(nameof(ConvertingEntity.StringToGuid), "uuid", false)]
[InlineData(nameof(ConvertingEntity.StringToNullableGuid), "uuid", false)]
[InlineData(nameof(ConvertingEntity.StringToNumber), "smallint", false)]
[InlineData(nameof(ConvertingEntity.StringToNullableNumber), "smallint", false)]
[InlineData(nameof(ConvertingEntity.StringToTimeSpan), "interval", false)]
[InlineData(nameof(ConvertingEntity.StringToNullableTimeSpan), "interval", false)]
[InlineData(nameof(ConvertingEntity.TimeSpanToTicks), "bigint", false)]
[InlineData(nameof(ConvertingEntity.TimeSpanToNullableTicks), "bigint", false)]
[InlineData(nameof(ConvertingEntity.TimeSpanToString), "character varying(48)", false)]
[InlineData(nameof(ConvertingEntity.TimeSpanToNullableString), "character varying(48)", false)]
[InlineData(nameof(ConvertingEntity.UriToString), "text", false)]
[InlineData(nameof(ConvertingEntity.UriToNullableString), "text", false)]
[InlineData(nameof(ConvertingEntity.NullableCharAsString), "character varying(1)", true)]
[InlineData(nameof(ConvertingEntity.NullableCharAsNullableString), "character varying(1)", true)]
[InlineData(nameof(ConvertingEntity.NullableBoolAsChar), "character(1)", true)]
[InlineData(nameof(ConvertingEntity.NullableBoolAsNullableChar), "character(1)", true)]
[InlineData(nameof(ConvertingEntity.NullableBoolAsString), "character varying(3)", true)]
[InlineData(nameof(ConvertingEntity.NullableBoolAsNullableString), "character varying(3)", true)]
[InlineData(nameof(ConvertingEntity.NullableBoolAsInt), "integer", true)]
[InlineData(nameof(ConvertingEntity.NullableBoolAsNullableInt), "integer", true)]
[InlineData(nameof(ConvertingEntity.NullableIntAsLong), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableIntAsNullableLong), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableBytesAsString), "text", true)]
[InlineData(nameof(ConvertingEntity.NullableBytesAsNullableString), "text", true)]
[InlineData(nameof(ConvertingEntity.NullableDateTimeOffsetToBinary), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableDateTimeOffsetToNullableBinary), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableDateTimeOffsetToString), "character varying(48)", true)]
[InlineData(nameof(ConvertingEntity.NullableDateTimeOffsetToNullableString), "character varying(48)", true)]
[InlineData(nameof(ConvertingEntity.NullableDateTimeToBinary), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableDateTimeToNullableBinary), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableDateTimeToString), "character varying(48)", true)]
[InlineData(nameof(ConvertingEntity.NullableDateTimeToNullableString), "character varying(48)", true)]
[InlineData(nameof(ConvertingEntity.NullableEnumToString), "text", true)]
[InlineData(nameof(ConvertingEntity.NullableEnumToNullableString), "text", true)]
[InlineData(nameof(ConvertingEntity.NullableEnumToNumber), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableEnumToNullableNumber), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableGuidToString), "character varying(36)", true)]
[InlineData(nameof(ConvertingEntity.NullableGuidToNullableString), "character varying(36)", true)]
[InlineData(nameof(ConvertingEntity.NullableGuidToBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullableGuidToNullableBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullableIPAddressToString), "character varying(45)", true)]
[InlineData(nameof(ConvertingEntity.NullableIPAddressToNullableString), "character varying(45)", true)]
[InlineData(nameof(ConvertingEntity.NullableIPAddressToBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullableIPAddressToNullableBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullablePhysicalAddressToString), "character varying(20)", true)]
[InlineData(nameof(ConvertingEntity.NullablePhysicalAddressToNullableString), "character varying(20)", true)]
[InlineData(nameof(ConvertingEntity.NullablePhysicalAddressToBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullablePhysicalAddressToNullableBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullableNumberToString), "character varying(64)", true)]
[InlineData(nameof(ConvertingEntity.NullableNumberToNullableString), "character varying(64)", true)]
[InlineData(nameof(ConvertingEntity.NullableNumberToBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullableNumberToNullableBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToBool), "boolean", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToNullableBool), "boolean", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToNullableBytes), "bytea", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToChar), "character(1)", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToNullableChar), "character(1)", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToDateTime), "timestamp without time zone", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToNullableDateTime), "timestamp without time zone", true)]
//[InlineData(nameof(ConvertingEntity.NullableStringToDateTimeOffset), "timestamp with time zone", true)]
//[InlineData(nameof(ConvertingEntity.NullableStringToNullableDateTimeOffset), "timestamp with time zone", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToEnum), "integer", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToNullableEnum), "integer", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToGuid), "uuid", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToNullableGuid), "uuid", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToNumber), "smallint", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToNullableNumber), "smallint", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToTimeSpan), "interval", true)]
[InlineData(nameof(ConvertingEntity.NullableStringToNullableTimeSpan), "interval", true)]
[InlineData(nameof(ConvertingEntity.NullableTimeSpanToTicks), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableTimeSpanToNullableTicks), "bigint", true)]
[InlineData(nameof(ConvertingEntity.NullableTimeSpanToString), "character varying(48)", true)]
[InlineData(nameof(ConvertingEntity.NullableTimeSpanToNullableString), "character varying(48)", true)]
[InlineData(nameof(ConvertingEntity.NullableUriToString), "text", true)]
[InlineData(nameof(ConvertingEntity.NullableUriToNullableString), "text", true)]
[InlineData(nameof(ConvertingEntity.NullStringToNonNullString), "text", false)]
[InlineData(nameof(ConvertingEntity.NonNullStringToNullString), "text", true)]
public virtual void Properties_with_conversions_map_to_appropriately_null_columns(
string propertyName,
string databaseType,
bool isNullable)
{
using var context = CreateContext();
var property = context.Model.FindEntityType(typeof(ConvertingEntity))!.FindProperty(propertyName);
Assert.Equal(databaseType, property!.GetColumnType());
Assert.Equal(isNullable, property!.IsNullable);
}
public class ValueConvertersEndToEndSqlServerFixture : ValueConvertersEndToEndFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);
modelBuilder.Entity<ConvertingEntity>(
b =>
{
// We map DateTimeOffset to PG 'timestamp with time zone', which doesn't store the time zone - so lossless
// round-tripping is impossible.
b.Ignore(e => e.StringToDateTimeOffset);
b.Ignore(e => e.StringToNullableDateTimeOffset);
b.Ignore(e => e.NullableStringToDateTimeOffset);
b.Ignore(e => e.NullableStringToNullableDateTimeOffset);
});
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册