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
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<EFCoreVersion>11.0.0-preview.2.26154.117</EFCoreVersion>
<MicrosoftExtensionsVersion>11.0.0-preview.2.26154.117</MicrosoftExtensionsVersion>
<MicrosoftExtensionsConfigurationVersion>11.0.0-preview.2.26154.117</MicrosoftExtensionsConfigurationVersion>
<EFCoreVersion>11.0.0-preview.3.26155.101</EFCoreVersion>
<MicrosoftExtensionsVersion>11.0.0-preview.3.26155.101</MicrosoftExtensionsVersion>
<MicrosoftExtensionsConfigurationVersion>11.0.0-preview.3.26155.101</MicrosoftExtensionsConfigurationVersion>
<NpgsqlVersion>10.0.0</NpgsqlVersion>
</PropertyGroup>

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

public class NonSharedModelBulkUpdatesNpgsqlTest(NonSharedFixture fixture) : NonSharedModelBulkUpdatesRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;


Expand Down Expand Up @@ -149,7 +149,7 @@ public override async Task Update_owned_and_non_owned_properties_with_table_shar
public override async Task Update_main_table_in_entity_with_entity_splitting(bool async)
{
// Overridden/duplicated because we update DateTime, which Npgsql requires to be a UTC timestamp
var contextFactory = await InitializeAsync<DbContext>(
var contextFactory = await InitializeNonSharedTest<DbContext>(
onModelCreating: mb => mb.Entity<Blog>()
.ToTable("Blogs")
.SplitToTable(
Expand All @@ -166,7 +166,7 @@ public override async Task Update_main_table_in_entity_with_entity_splitting(boo

await AssertUpdate(
async,
contextFactory.CreateContext,
contextFactory.CreateDbContext,
ss => ss.Set<Blog>(),
s => s.SetProperty(b => b.CreationTimestamp, b => new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc)),
rowsAffectedCount: 1);
Expand Down Expand Up @@ -226,7 +226,7 @@ SELECT COALESCE(sum(o0."Amount"), 0)::int
[MemberData(nameof(IsAsyncData))]
public virtual async Task Update_with_primitive_collection_in_value_selector(bool async)
{
var contextFactory = await InitializeAsync<Context3001>(
var contextFactory = await InitializeNonSharedTest<Context3001>(
seed: async ctx =>
{
ctx.AddRange(new EntityWithPrimitiveCollection { Tags = ["tag1", "tag2"] });
Expand All @@ -235,7 +235,7 @@ public virtual async Task Update_with_primitive_collection_in_value_selector(boo

await Assert.ThrowsAsync<InvalidOperationException>(() => AssertUpdate(
async,
contextFactory.CreateContext,
contextFactory.CreateDbContext,
ss => ss.EntitiesWithPrimitiveCollection,
s => s.SetProperty(x => x.Tags, x => x.Tags.Append("another_tag")),
rowsAffectedCount: 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,33 @@ ORDER BY o1."OrderID" NULLS FIRST
""");
}

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

AssertSql(
"""
@p='Updated'

UPDATE "Customers" AS c
SET "ContactName" = @p
""");
}

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

AssertSql(
"""
@p='Updated'

UPDATE "Customers" AS c
SET "ContactName" = @p
""");
}


[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 @@ -3,6 +3,6 @@ namespace Microsoft.EntityFrameworkCore;
public class EntitySplittingNpgsqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper)
: EntitySplittingTestBase(fixture, testOutputHelper)
{
protected override ITestStoreFactory TestStoreFactory
protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
}
4 changes: 2 additions & 2 deletions test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,12 @@ protected class LogSequenceNumberType
public NpgsqlLogSequenceNumber LogSequenceNumber { get; set; }
}

protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance;
protected override ITestStoreFactory NonSharedTestStoreFactory => NpgsqlTestStoreFactory.Instance;

protected override IServiceCollection AddServices(IServiceCollection serviceCollection)
=> serviceCollection.AddEntityFrameworkNpgsqlNetTopologySuite();

protected override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
protected override DbContextOptionsBuilder AddNonSharedOptions(DbContextOptionsBuilder builder)
{
// Note that the enum doesn't actually need to be created in the database, since Can_read_and_write_JSON_value doesn't access
// the database. We just need the mapping to be picked up by EFCore.PG from the ADO.NET layer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
}

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

// Cannot write DateTime with Kind=Unspecified to PostgreSQL type 'timestamp with time zone', only UTC is supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ LIMIT 2
""");
}

protected override ITestStoreFactory TestStoreFactory
protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
}
10 changes: 5 additions & 5 deletions test/EFCore.PG.FunctionalTests/Query/AdHocJsonQueryNpgsqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Query;

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

protected override async Task Seed29219(DbContext ctx)
Expand Down Expand Up @@ -179,7 +179,7 @@ protected override Task SeedBadJsonProperties(ContextBadJsonProperties ctx)
[ConditionalTheory, MemberData(nameof(IsAsyncData))]
public virtual async Task Json_predicate_on_bytea(bool async)
{
var contextFactory = await InitializeAsync<TypesDbContext>(
var contextFactory = await InitializeNonSharedTest<TypesDbContext>(
seed: async context =>
{
context.Entities.AddRange(
Expand All @@ -188,7 +188,7 @@ public virtual async Task Json_predicate_on_bytea(bool async)
await context.SaveChangesAsync();
});

using (var context = contextFactory.CreateContext())
using (var context = contextFactory.CreateDbContext())
{
var query = context.Entities.Where(x => x.JsonEntity.Bytea == new byte[] { 1, 2, 4 });

Expand All @@ -211,7 +211,7 @@ LIMIT 2
[ConditionalTheory, MemberData(nameof(IsAsyncData))]
public virtual async Task Json_predicate_on_interval(bool async)
{
var contextFactory = await InitializeAsync<TypesDbContext>(
var contextFactory = await InitializeNonSharedTest<TypesDbContext>(
seed: async context =>
{
context.Entities.AddRange(
Expand All @@ -220,7 +220,7 @@ public virtual async Task Json_predicate_on_interval(bool async)
await context.SaveChangesAsync();
});

using (var context = contextFactory.CreateContext())
using (var context = contextFactory.CreateDbContext())
{
var query = context.Entities.Where(x => x.JsonEntity.Interval == new TimeSpan(2, 2, 3, 4, 123, 456));

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

public class AdHocManyToManyQueryNpgsqlTest(NonSharedFixture fixture) : AdHocManyToManyQueryRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocMiscellaneousQueryNpgsqlTest(NonSharedFixture fixture) : AdHocMiscellaneousQueryRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;

protected override DbContextOptionsBuilder SetParameterizedCollectionMode(DbContextOptionsBuilder optionsBuilder, ParameterTranslationMode parameterizedCollectionMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public class AdHocNavigationsQueryNpgsqlTest(NonSharedFixture fixture) : AdHocNa
public override Task Reference_include_on_derived_type_with_sibling_works()
=> Assert.ThrowsAsync<DbUpdateException>(() => base.Reference_include_on_derived_type_with_sibling_works());

protected override ITestStoreFactory TestStoreFactory
protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ public override async Task Projecting_entity_with_property_requiring_converter_w
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());

protected override ITestStoreFactory TestStoreFactory
protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;

protected override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers
=> NpgsqlPrecompiledQueryTestHelpers.Instance;

protected override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
protected override DbContextOptionsBuilder AddNonSharedOptions(DbContextOptionsBuilder builder)
{
builder = base.AddOptions(builder);
builder = base.AddNonSharedOptions(builder);

// TODO: Figure out if there's a nice way to continue using the retrying strategy
var sqlServerOptionsBuilder = new NpgsqlDbContextOptionsBuilder(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Microsoft.EntityFrameworkCore.Query;
public class AdHocQueryFiltersQueryNpgsqlTest(NonSharedFixture fixture)
: AdHocQueryFiltersQueryRelationalTestBase(fixture)
{
protected override ITestStoreFactory TestStoreFactory
protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query;

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

private static readonly FieldInfo _querySplittingBehaviorFieldInfo =
Expand Down Expand Up @@ -41,7 +41,7 @@ protected override DbContextOptionsBuilder ClearQuerySplittingBehavior(DbContext

protected override TestStore CreateTestStore25225()
{
var testStore = NpgsqlTestStore.Create(StoreName);
var testStore = NpgsqlTestStore.Create(NonSharedStoreName);
testStore.UseConnectionString = true;
return testStore;
}
Expand Down
11 changes: 4 additions & 7 deletions test/EFCore.PG.FunctionalTests/Query/ArrayQueryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Microsoft.EntityFrameworkCore.Query;

public abstract class ArrayQueryFixture : SharedStoreFixtureBase<ArrayQueryContext>, IQueryFixtureBase, ITestSqlLoggerFactory
public abstract class ArrayQueryFixture : QueryFixtureBase<ArrayQueryContext>, ITestSqlLoggerFactory
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
Expand All @@ -18,19 +18,16 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
protected override Task SeedAsync(ArrayQueryContext context)
=> ArrayQueryContext.SeedAsync(context);

public Func<DbContext> GetContextCreator()
=> CreateContext;

public ISetSource GetExpectedData()
public override ISetSource GetExpectedData()
=> _expectedData ??= new ArrayQueryData();

public IReadOnlyDictionary<Type, object> EntitySorters
public override IReadOnlyDictionary<Type, object> EntitySorters
=> new Dictionary<Type, Func<object, object?>>
{
{ typeof(ArrayEntity), e => ((ArrayEntity)e).Id }, { typeof(ArrayContainerEntity), e => ((ArrayContainerEntity)e)?.Id }
}.ToDictionary(e => e.Key, e => (object)e.Value);

public IReadOnlyDictionary<Type, object> EntityAsserters
public override IReadOnlyDictionary<Type, object> EntityAsserters
=> new Dictionary<Type, Action<object, object>>
{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,28 @@ ORDER BY v."Id" NULLS FIRST

#endregion Value types

public override async Task Select_subquery_FirstOrDefault_complex_collection(QueryTrackingBehavior queryTrackingBehavior)
{
await base.Select_subquery_FirstOrDefault_complex_collection(queryTrackingBehavior);

if (queryTrackingBehavior is not QueryTrackingBehavior.TrackAll)
{
AssertSql(
"""
SELECT r1.c, r1.c0
FROM "RootEntity" AS r
LEFT JOIN LATERAL (
SELECT r0."AssociateCollection" AS c, 1 AS c0
FROM "RootEntity" AS r0
ORDER BY r0."Id" NULLS FIRST
LIMIT 1
) AS r1 ON TRUE
ORDER BY r."Id" NULLS FIRST
""");
}
}


[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 @@ -350,6 +350,28 @@ ORDER BY v."Id" NULLS FIRST

#endregion Value types

public override async Task Select_subquery_FirstOrDefault_complex_collection(QueryTrackingBehavior queryTrackingBehavior)
{
await base.Select_subquery_FirstOrDefault_complex_collection(queryTrackingBehavior);

if (queryTrackingBehavior is not QueryTrackingBehavior.TrackAll)
{
AssertSql(
"""
SELECT r1."Id", r1."Name", r1."OptionalAssociate_Id", r1."OptionalAssociate_Int", r1."OptionalAssociate_Ints", r1."OptionalAssociate_Name", r1."OptionalAssociate_String", r1."OptionalAssociate_OptionalNestedAssociate_Id", r1."OptionalAssociate_OptionalNestedAssociate_Int", r1."OptionalAssociate_OptionalNestedAssociate_Ints", r1."OptionalAssociate_OptionalNestedAssociate_Name", r1."OptionalAssociate_OptionalNestedAssociate_String", r1."OptionalAssociate_RequiredNestedAssociate_Id", r1."OptionalAssociate_RequiredNestedAssociate_Int", r1."OptionalAssociate_RequiredNestedAssociate_Ints", r1."OptionalAssociate_RequiredNestedAssociate_Name", r1."OptionalAssociate_RequiredNestedAssociate_String", r1."RequiredAssociate_Id", r1."RequiredAssociate_Int", r1."RequiredAssociate_Ints", r1."RequiredAssociate_Name", r1."RequiredAssociate_String", r1."RequiredAssociate_OptionalNestedAssociate_Id", r1."RequiredAssociate_OptionalNestedAssociate_Int", r1."RequiredAssociate_OptionalNestedAssociate_Ints", r1."RequiredAssociate_OptionalNestedAssociate_Name", r1."RequiredAssociate_OptionalNestedAssociate_String", r1."RequiredAssociate_RequiredNestedAssociate_Id", r1."RequiredAssociate_RequiredNestedAssociate_Int", r1."RequiredAssociate_RequiredNestedAssociate_Ints", r1."RequiredAssociate_RequiredNestedAssociate_Name", r1."RequiredAssociate_RequiredNestedAssociate_String", r1.c
FROM "RootEntity" AS r
LEFT JOIN LATERAL (
SELECT r0."Id", r0."Name", r0."OptionalAssociate_Id", r0."OptionalAssociate_Int", r0."OptionalAssociate_Ints", r0."OptionalAssociate_Name", r0."OptionalAssociate_String", r0."OptionalAssociate_OptionalNestedAssociate_Id", r0."OptionalAssociate_OptionalNestedAssociate_Int", r0."OptionalAssociate_OptionalNestedAssociate_Ints", r0."OptionalAssociate_OptionalNestedAssociate_Name", r0."OptionalAssociate_OptionalNestedAssociate_String", r0."OptionalAssociate_RequiredNestedAssociate_Id", r0."OptionalAssociate_RequiredNestedAssociate_Int", r0."OptionalAssociate_RequiredNestedAssociate_Ints", r0."OptionalAssociate_RequiredNestedAssociate_Name", r0."OptionalAssociate_RequiredNestedAssociate_String", r0."RequiredAssociate_Id", r0."RequiredAssociate_Int", r0."RequiredAssociate_Ints", r0."RequiredAssociate_Name", r0."RequiredAssociate_String", r0."RequiredAssociate_OptionalNestedAssociate_Id", r0."RequiredAssociate_OptionalNestedAssociate_Int", r0."RequiredAssociate_OptionalNestedAssociate_Ints", r0."RequiredAssociate_OptionalNestedAssociate_Name", r0."RequiredAssociate_OptionalNestedAssociate_String", r0."RequiredAssociate_RequiredNestedAssociate_Id", r0."RequiredAssociate_RequiredNestedAssociate_Int", r0."RequiredAssociate_RequiredNestedAssociate_Ints", r0."RequiredAssociate_RequiredNestedAssociate_Name", r0."RequiredAssociate_RequiredNestedAssociate_String", 1 AS c
FROM "RootEntity" AS r0
ORDER BY r0."Id" NULLS FIRST
LIMIT 1
) AS r1 ON TRUE
ORDER BY r."Id" NULLS FIRST
""");
}
}


[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 @@ -409,6 +409,35 @@ LIMIT 1

#endregion Subquery

public override async Task Select_subquery_FirstOrDefault_complex_collection(QueryTrackingBehavior queryTrackingBehavior)
{
await base.Select_subquery_FirstOrDefault_complex_collection(queryTrackingBehavior);

if (queryTrackingBehavior is not QueryTrackingBehavior.TrackAll)
{
AssertSql(
"""
SELECT r."Id", r1."Id", s."Id", s."CollectionRootId", s."Int", s."Ints", s."Name", s."OptionalNestedAssociateId", s."RequiredNestedAssociateId", s."String", s."Id0", s."Id1", s."Id2", s."CollectionAssociateId", s."Int0", s."Ints0", s."Name0", s."String0", s."CollectionAssociateId0", s."Int1", s."Ints1", s."Name1", s."String1", s."CollectionAssociateId1", s."Int2", s."Ints2", s."Name2", s."String2", r1.c
FROM "RootEntity" AS r
LEFT JOIN LATERAL (
SELECT 1 AS c, r0."Id"
FROM "RootEntity" AS r0
ORDER BY r0."Id" NULLS FIRST
LIMIT 1
) AS r1 ON TRUE
LEFT JOIN (
SELECT a."Id", a."CollectionRootId", a."Int", a."Ints", a."Name", a."OptionalNestedAssociateId", a."RequiredNestedAssociateId", a."String", n."Id" AS "Id0", n0."Id" AS "Id1", n1."Id" AS "Id2", n1."CollectionAssociateId", n1."Int" AS "Int0", n1."Ints" AS "Ints0", n1."Name" AS "Name0", n1."String" AS "String0", n."CollectionAssociateId" AS "CollectionAssociateId0", n."Int" AS "Int1", n."Ints" AS "Ints1", n."Name" AS "Name1", n."String" AS "String1", n0."CollectionAssociateId" AS "CollectionAssociateId1", n0."Int" AS "Int2", n0."Ints" AS "Ints2", n0."Name" AS "Name2", n0."String" AS "String2"
FROM "AssociateType" AS a
LEFT JOIN "NestedAssociateType" AS n ON a."OptionalNestedAssociateId" = n."Id"
INNER JOIN "NestedAssociateType" AS n0 ON a."RequiredNestedAssociateId" = n0."Id"
LEFT JOIN "NestedAssociateType" AS n1 ON a."Id" = n1."CollectionAssociateId"
) AS s ON r1."Id" = s."CollectionRootId"
ORDER BY r."Id" NULLS FIRST, r1."Id" NULLS FIRST, s."Id" NULLS FIRST, s."Id0" NULLS FIRST, s."Id1" NULLS FIRST
""");
}
}


[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());
Expand Down
Loading