Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>10.0.0-preview.3</VersionPrefix>
<VersionPrefix>10.0.0-preview.4</VersionPrefix>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<EFCoreVersion>10.0.0-preview.3.25171.6</EFCoreVersion>
<MicrosoftExtensionsVersion>10.0.0-preview.3.25171.5</MicrosoftExtensionsVersion>
<EFCoreVersion>10.0.0-preview.4.25258.110</EFCoreVersion>
<MicrosoftExtensionsVersion>10.0.0-preview.4.25258.110</MicrosoftExtensionsVersion>
<NpgsqlVersion>9.0.3</NpgsqlVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "10.0.100-preview.2.25081.1",
"version": "10.0.100-preview.4.25258.110",
"rollForward": "latestMajor",
"allowPrerelease": true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.EntityFrameworkCore.BulkUpdates;

public class NonSharedModelBulkUpdatesNpgsqlTest : NonSharedModelBulkUpdatesRelationalTestBase
public class NonSharedModelBulkUpdatesNpgsqlTest(NonSharedFixture fixture) : NonSharedModelBulkUpdatesRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<PackageReference Include="xunit.core" />
</ItemGroup>

<!-- Temporary, remove after sync to latest EF preview -->
<ItemGroup>
<NuGetAuditSuppress Include="https://github.com/advisories/GHSA-h4j7-5rxr-p4wc" />
</ItemGroup>

<ItemGroup>
<None Update="Northwind.sql" CopyToOutputDirectory="PreserveNewest" />
<None Update="config.json" CopyToOutputDirectory="PreserveNewest" />
Expand Down
3 changes: 2 additions & 1 deletion test/EFCore.PG.FunctionalTests/EntitySplittingNpgsqlTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Microsoft.EntityFrameworkCore;

public class EntitySplittingNpgsqlTest(ITestOutputHelper testOutputHelper) : EntitySplittingTestBase(testOutputHelper)
public class EntitySplittingNpgsqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper)
: EntitySplittingTestBase(fixture, testOutputHelper)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
Expand Down
2 changes: 1 addition & 1 deletion test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.EntityFrameworkCore;

public class JsonTypesNpgsqlTest : JsonTypesRelationalTestBase
public class JsonTypesNpgsqlTest(NonSharedFixture fixture) : JsonTypesRelationalTestBase(fixture)
{
#region Nested collections (unsupported)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Microsoft.EntityFrameworkCore;

public class MaterializationInterceptionNpgsqlTest :
MaterializationInterceptionTestBase<MaterializationInterceptionNpgsqlTest.NpgsqlLibraryContext>
public class MaterializationInterceptionNpgsqlTest(NonSharedFixture fixture) :
MaterializationInterceptionTestBase<MaterializationInterceptionNpgsqlTest.NpgsqlLibraryContext>(fixture)
{
public class NpgsqlLibraryContext(DbContextOptions options) : LibraryContext(options)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ protected override TestModelBuilder CreateModelBuilder(
=> new GenericTestModelBuilder(Fixture, configure);
}

public class NpgsqlGenericComplexCollection(NpgsqlModelBuilderFixture fixture) : NpgsqlComplexCollection(fixture)
{
protected override TestModelBuilder CreateModelBuilder(
Action<ModelConfigurationBuilder>? configure)
=> new GenericTestModelBuilder(Fixture, configure);
}

public class NpgsqlGenericInheritance(NpgsqlModelBuilderFixture fixture) : NpgsqlInheritance(fixture)
{
protected override TestModelBuilder CreateModelBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public abstract class NpgsqlNonRelationship(NpgsqlModelBuilderFixture fixture)
public abstract class NpgsqlComplexType(NpgsqlModelBuilderFixture fixture)
: RelationalComplexTypeTestBase(fixture), IClassFixture<NpgsqlModelBuilderFixture>;

public abstract class NpgsqlComplexCollection(NpgsqlModelBuilderFixture fixture)
: RelationalComplexCollectionTestBase(fixture), IClassFixture<NpgsqlModelBuilderFixture>;

public abstract class NpgsqlInheritance(NpgsqlModelBuilderFixture fixture)
: RelationalInheritanceTestBase(fixture), IClassFixture<NpgsqlModelBuilderFixture>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocAdvancedMappingsQueryNpgsqlTest : AdHocAdvancedMappingsQueryRelationalTestBase
public class AdHocAdvancedMappingsQueryNpgsqlTest(NonSharedFixture fixture)
: AdHocAdvancedMappingsQueryRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocComplexTypeQueryNpgsqlTest : AdHocComplexTypeQueryTestBase
public class AdHocComplexTypeQueryNpgsqlTest(NonSharedFixture fixture) : AdHocComplexTypeQueryTestBase(fixture)
{
public override async Task Complex_type_equals_parameter_with_nested_types_with_property_of_same_name()
{
Expand Down
82 changes: 22 additions & 60 deletions test/EFCore.PG.FunctionalTests/Query/AdHocJsonQueryNpgsqlTest.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
using Xunit.Sdk;

namespace Microsoft.EntityFrameworkCore.Query;

#nullable disable

public class AdHocJsonQueryNpgsqlTest : AdHocJsonQueryRelationalTestBase
public class AdHocJsonQueryNpgsqlTest(NonSharedFixture fixture) : AdHocJsonQueryRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;

protected override async Task Seed29219(DbContext ctx)
{
var entity1 = new MyEntity29219
var entity1 = new Context29219.MyEntity
{
Id = 1,
Reference = new MyJsonEntity29219 { NonNullableScalar = 10, NullableScalar = 11 },
Reference = new Context29219.MyJsonEntity { NonNullableScalar = 10, NullableScalar = 11 },
Collection =
[
new() { NonNullableScalar = 100, NullableScalar = 101 },
Expand All @@ -21,10 +23,10 @@ protected override async Task Seed29219(DbContext ctx)
]
};

var entity2 = new MyEntity29219
var entity2 = new Context29219.MyEntity
{
Id = 2,
Reference = new MyJsonEntity29219 { NonNullableScalar = 20, NullableScalar = null },
Reference = new Context29219.MyJsonEntity { NonNullableScalar = 20, NullableScalar = null },
Collection = [new() { NonNullableScalar = 1001, NullableScalar = null }]
};

Expand Down Expand Up @@ -84,52 +86,6 @@ protected override async Task Seed33046(DbContext ctx)
VALUES('[{"RoundNumber":11,"SubRounds":[{"SubRoundNumber":111},{"SubRoundNumber":112}]}]', 1)
""");

protected override async Task SeedArrayOfPrimitives(DbContext ctx)
{
var entity1 = new MyEntityArrayOfPrimitives
{
Id = 1,
Reference = new MyJsonEntityArrayOfPrimitives
{
IntArray = [1, 2, 3],
ListOfString =
[
"Foo",
"Bar",
"Baz"
]
},
Collection =
[
new() { IntArray = [111, 112, 113], ListOfString = ["Foo11", "Bar11"] },
new() { IntArray = [211, 212, 213], ListOfString = ["Foo12", "Bar12"] }
]
};

var entity2 = new MyEntityArrayOfPrimitives
{
Id = 2,
Reference = new MyJsonEntityArrayOfPrimitives
{
IntArray = [10, 20, 30],
ListOfString =
[
"A",
"B",
"C"
]
},
Collection =
[
new() { IntArray = [110, 120, 130], ListOfString = ["A1", "Z1"] },
new() { IntArray = [210, 220, 230], ListOfString = ["A2", "Z2"] }
]
};

ctx.AddRange(entity1, entity2);
await ctx.SaveChangesAsync();
}

protected override async Task SeedJunkInJson(DbContext ctx)
=> await ctx.Database.ExecuteSqlAsync(
$$$"""
Expand Down Expand Up @@ -186,11 +142,17 @@ await ctx.Database.ExecuteSqlAsync(

// PostgreSQL stores JSON as jsonb, which doesn't allow badly-formed JSON; so the following tests are irrelevant.

public override Task Bad_json_properties_duplicated_navigations_tracking()
=> Assert.ThrowsAsync<NotSupportedException>(() => base.Bad_json_properties_duplicated_navigations_tracking());

public override Task Bad_json_properties_duplicated_navigations_no_tracking()
=> Assert.ThrowsAsync<NotSupportedException>(() => base.Bad_json_properties_duplicated_navigations_no_tracking());
public override async Task Bad_json_properties_duplicated_navigations(bool noTracking)
{
if (noTracking)
{
await Assert.ThrowsAsync<NotSupportedException>(() => base.Bad_json_properties_duplicated_navigations(noTracking: true));
}
else
{
await base.Bad_json_properties_duplicated_navigations(noTracking: false);
}
}

public override Task Bad_json_properties_duplicated_scalars(bool noTracking)
=> Assert.ThrowsAsync<NotSupportedException>(() => base.Bad_json_properties_duplicated_scalars(noTracking));
Expand All @@ -202,10 +164,10 @@ public override Task Bad_json_properties_empty_scalars(bool noTracking)
=> Assert.ThrowsAsync<NotSupportedException>(() => base.Bad_json_properties_empty_scalars(noTracking));

public override Task Bad_json_properties_null_navigations(bool noTracking)
=> Assert.ThrowsAsync<NotSupportedException>(() => base.Bad_json_properties_null_navigations(noTracking));
=> Assert.ThrowsAsync<ThrowsAnyException>(() => base.Bad_json_properties_null_navigations(noTracking));

public override Task Bad_json_properties_null_scalars(bool noTracking)
=> Assert.ThrowsAsync<NotSupportedException>(() => base.Bad_json_properties_null_scalars(noTracking));
=> Assert.ThrowsAsync<ThrowsAnyException>(() => base.Bad_json_properties_null_scalars(noTracking));

protected override Task SeedBadJsonProperties(ContextBadJsonProperties ctx)
=> throw new NotSupportedException("PostgreSQL stores JSON as jsonb, which doesn't allow badly-formed JSON");
Expand Down Expand Up @@ -304,10 +266,10 @@ public override Task Project_entity_with_json_null_values()
=> Assert.ThrowsAsync<ArgumentException>(() => base.Project_entity_with_json_null_values());

public override Task Try_project_collection_but_JSON_is_entity()
=> Assert.ThrowsAsync<ArgumentException>(() => base.Try_project_collection_but_JSON_is_entity());
=> Assert.ThrowsAsync<ThrowsException>(() => base.Try_project_collection_but_JSON_is_entity());

public override Task Try_project_reference_but_JSON_is_collection()
=> Assert.ThrowsAsync<ArgumentException>(() => base.Try_project_reference_but_JSON_is_collection());
=> Assert.ThrowsAsync<ThrowsException>(() => base.Try_project_reference_but_JSON_is_collection());

public override Task Project_entity_with_optional_json_entity_owned_by_required_json()
=> Assert.ThrowsAsync<ArgumentException>(() => base.Project_entity_with_optional_json_entity_owned_by_required_json());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocManyToManyQueryNpgsqlTest : AdHocManyToManyQueryRelationalTestBase
public class AdHocManyToManyQueryNpgsqlTest(NonSharedFixture fixture) : AdHocManyToManyQueryRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocMiscellaneousQueryNpgsqlTest : AdHocMiscellaneousQueryRelationalTestBase
public class AdHocMiscellaneousQueryNpgsqlTest(NonSharedFixture fixture) : AdHocMiscellaneousQueryRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocNavigationsQueryNpgsqlTest : AdHocNavigationsQueryRelationalTestBase
public class AdHocNavigationsQueryNpgsqlTest(NonSharedFixture fixture) : AdHocNavigationsQueryRelationalTestBase(fixture)
{
// Cannot write DateTime with Kind=Local to PostgreSQL type 'timestamp with time zone', only UTC is supported.
public override Task Reference_include_on_derived_type_with_sibling_works()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocPrecompiledQueryNpgsqlTest(ITestOutputHelper testOutputHelper)
: AdHocPrecompiledQueryRelationalTestBase(testOutputHelper)
public class AdHocPrecompiledQueryNpgsqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper)
: AdHocPrecompiledQueryRelationalTestBase(fixture, testOutputHelper)
{
protected override bool AlwaysPrintGeneratedSources
=> false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocQueryFiltersQueryNpgsqlTest : AdHocQueryFiltersQueryRelationalTestBase
public class AdHocQueryFiltersQueryNpgsqlTest(NonSharedFixture fixture)
: AdHocQueryFiltersQueryRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ namespace Microsoft.EntityFrameworkCore.Query;

#nullable disable

public class AdHocQuerySplittingQueryNpgsqlTest : AdHocQuerySplittingQueryTestBase
public class AdHocQuerySplittingQueryNpgsqlTest(NonSharedFixture fixture) : AdHocQuerySplittingQueryTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;

private static readonly FieldInfo _querySplittingBehaviorFieldInfo =
typeof(RelationalOptionsExtension).GetField("_querySplittingBehavior", BindingFlags.NonPublic | BindingFlags.Instance);

protected override DbContextOptionsBuilder SetQuerySplittingBehavior(
DbContextOptionsBuilder optionsBuilder,
QuerySplittingBehavior splittingBehavior)
Expand All @@ -33,9 +39,10 @@ protected override DbContextOptionsBuilder ClearQuerySplittingBehavior(DbContext
return optionsBuilder;
}

private static readonly FieldInfo _querySplittingBehaviorFieldInfo =
typeof(RelationalOptionsExtension).GetField("_querySplittingBehavior", BindingFlags.NonPublic | BindingFlags.Instance);

protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
protected override TestStore CreateTestStore25225()
{
var testStore = NpgsqlTestStore.Create(StoreName);
testStore.UseConnectionString = true;
return testStore;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
namespace Microsoft.EntityFrameworkCore.Query;

public class EntitySplittingQueryNpgsqlTest : EntitySplittingQueryTestBase
public class EntitySplittingQueryNpgsqlTest(NonSharedFixture fixture)
: EntitySplittingQueryTestBase(fixture)
{
public EntitySplittingQueryNpgsqlTest(ITestOutputHelper testOutputHelper)
{
}

[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Microsoft.EntityFrameworkCore.Query;

public class NonSharedPrimitiveCollectionsQueryNpgsqlTest : NonSharedPrimitiveCollectionsQueryRelationalTestBase
public class NonSharedPrimitiveCollectionsQueryNpgsqlTest(NonSharedFixture fixture)
: NonSharedPrimitiveCollectionsQueryRelationalTestBase(fixture)
{
#region Support for specific element types

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Microsoft.EntityFrameworkCore.Query;

public class OperatorsQueryNpgsqlTest : OperatorsQueryTestBase
public class OperatorsQueryNpgsqlTest(NonSharedFixture fixture) : OperatorsQueryTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.EntityFrameworkCore.Query;

public class OwnedEntityQueryNpgsqlTest : OwnedEntityQueryRelationalTestBase
public class OwnedEntityQueryNpgsqlTest(NonSharedFixture fixture) : OwnedEntityQueryRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,21 @@ WHERE CASE
""");
}

public override async Task Values_of_enum_casted_to_underlying_value(bool async)
{
await base.Values_of_enum_casted_to_underlying_value(async);

AssertSql(
"""
SELECT p."Id", p."Bool", p."Bools", p."DateTime", p."DateTimes", p."Enum", p."Enums", p."Int", p."Ints", p."NullableInt", p."NullableInts", p."NullableString", p."NullableStrings", p."NullableWrappedId", p."NullableWrappedIdWithNullableComparer", p."String", p."Strings", p."WrappedId"
FROM "PrimitiveCollectionsEntity" AS p
WHERE (
SELECT count(*)::int
FROM (VALUES (0::int), (1), (2), (3)) AS v("Value")
WHERE v."Value" = p."Int") > 0
""");
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task Array_remove(bool async)
Expand Down
Loading