Skip to content

Commit b2dce20

Browse files
rojiCopilot
andauthored
Sync to EF 11.0.0-preview.4.26215.121 (#3814)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6403717 commit b2dce20

5 files changed

Lines changed: 102 additions & 32 deletions

File tree

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
3-
<EFCoreVersion>11.0.0-preview.4.26210.110</EFCoreVersion>
4-
<MicrosoftExtensionsVersion>11.0.0-preview.4.26210.110</MicrosoftExtensionsVersion>
5-
<MicrosoftExtensionsConfigurationVersion>11.0.0-preview.4.26210.110</MicrosoftExtensionsConfigurationVersion>
3+
<EFCoreVersion>11.0.0-preview.4.26215.121</EFCoreVersion>
4+
<MicrosoftExtensionsVersion>11.0.0-preview.4.26215.121</MicrosoftExtensionsVersion>
5+
<MicrosoftExtensionsConfigurationVersion>11.0.0-preview.4.26215.121</MicrosoftExtensionsConfigurationVersion>
66
<NpgsqlVersion>10.0.0</NpgsqlVersion>
77
</PropertyGroup>
88

src/EFCore.PG/Migrations/Internal/NpgsqlHistoryRepository.cs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Migrations.Internal;
1111
/// </summary>
1212
public class NpgsqlHistoryRepository : HistoryRepository, IHistoryRepository
1313
{
14-
private IModel? _model;
15-
1614
/// <summary>
1715
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
1816
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -111,7 +109,9 @@ protected override IReadOnlyList<MigrationCommand> GetCreateCommands()
111109
// Note that the approach in EF is to remove specific conventions (e.g. DbSetFindingConvention), but we don't want to hardcode
112110
// specific conventions here; for example, the NetTopologySuite plugin has its NpgsqlNetTopologySuiteExtensionAddingConvention
113111
// which adds PostGIS. So we just filter out the annotations on the operations themselves.
112+
#pragma warning disable EF1001 // Internal EF Core API usage.
114113
var model = EnsureModel();
114+
#pragma warning restore EF1001 // Internal EF Core API usage.
115115

116116
var operations = Dependencies.ModelDiffer.GetDifferences(null, model.GetRelationalModel());
117117

@@ -135,30 +135,6 @@ protected override IReadOnlyList<MigrationCommand> GetCreateCommands()
135135
return Dependencies.MigrationsSqlGenerator.Generate(operations, model);
136136
}
137137

138-
// Copied as-is from EF's HistoryRepository, since it's private (see https://github.com/dotnet/efcore/issues/34991)
139-
private IModel EnsureModel()
140-
{
141-
if (_model == null)
142-
{
143-
var conventionSet = Dependencies.ConventionSetBuilder.CreateConventionSet();
144-
145-
conventionSet.Remove(typeof(DbSetFindingConvention));
146-
conventionSet.Remove(typeof(RelationalDbFunctionAttributeConvention));
147-
148-
var modelBuilder = new ModelBuilder(conventionSet);
149-
modelBuilder.Entity<HistoryRow>(x =>
150-
{
151-
ConfigureTable(x);
152-
x.ToTable(TableName, TableSchema);
153-
});
154-
155-
_model = Dependencies.ModelRuntimeInitializer.Initialize(
156-
(IModel)modelBuilder.Model, designTime: true, validationLogger: null);
157-
}
158-
159-
return _model;
160-
}
161-
162138
bool IHistoryRepository.CreateIfNotExists()
163139
{
164140
// In PG, doing CREATE TABLE IF NOT EXISTS isn't concurrency-safe, and can result a "duplicate table" error or in a unique

test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ public override Task Can_read_write_nullable_TimeSpan_JSON_values(string? value,
155155
// Cannot override since the base test contains [InlineData] attributes which still apply, and which contain data we need
156156
// to override. See Can_read_write_nullable_TimeSpan_JSON_values_npgsql instead.
157157
// TODO: Implement Can_read_write_collection_of_TimeSpan_JSON_values_npgsql
158-
public override Task Can_read_write_collection_of_TimeSpan_JSON_values()
158+
public override Task Can_read_write_collection_of_TimeSpan_JSON_values(string expected)
159159
=> Task.CompletedTask;
160160

161161
// Cannot override since the base test contains [InlineData] attributes which still apply, and which contain data we need
162162
// to override. See Can_read_write_nullable_TimeSpan_JSON_values_npgsql instead.
163163
// TODO: Implement Can_read_write_collection_of_nullable_TimeSpan_JSON_values_npgsql
164-
public override Task Can_read_write_collection_of_nullable_TimeSpan_JSON_values()
165-
=> Task.CompletedTask;
164+
public override Task Can_read_write_collection_of_nullable_TimeSpan_JSON_values(string expected)
165+
=> Task.CompletedTask;
166166

167167
#endregion TimeSpan
168168

test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,6 +2355,63 @@ public override async Task Project_inline_collection_with_Concat()
23552355
AssertSql();
23562356
}
23572357

2358+
public override async Task Parameter_collection_of_enum_Cast_from_different_enum_type(ParameterTranslationMode mode)
2359+
{
2360+
await base.Parameter_collection_of_enum_Cast_from_different_enum_type(mode);
2361+
2362+
switch (mode)
2363+
{
2364+
case ParameterTranslationMode.Constant:
2365+
{
2366+
AssertSql(
2367+
"""
2368+
SELECT t."Id"
2369+
FROM "TestEntity38008" AS t
2370+
WHERE EXISTS (
2371+
SELECT 1
2372+
FROM (VALUES (2::int)) AS f("Value")
2373+
WHERE f."Value" = t."Status")
2374+
""");
2375+
break;
2376+
}
2377+
2378+
case ParameterTranslationMode.Parameter:
2379+
{
2380+
AssertSql(
2381+
"""
2382+
@filter={ '2' } (DbType = Object)
2383+
2384+
SELECT t."Id"
2385+
FROM "TestEntity38008" AS t
2386+
WHERE EXISTS (
2387+
SELECT 1
2388+
FROM unnest(@filter) AS f(value)
2389+
WHERE f.value = t."Status")
2390+
""");
2391+
break;
2392+
}
2393+
2394+
case ParameterTranslationMode.MultipleParameters:
2395+
{
2396+
AssertSql(
2397+
"""
2398+
@filter1='2'
2399+
2400+
SELECT t."Id"
2401+
FROM "TestEntity38008" AS t
2402+
WHERE EXISTS (
2403+
SELECT 1
2404+
FROM (VALUES (@filter1)) AS f("Value")
2405+
WHERE f."Value" = t."Status")
2406+
""");
2407+
break;
2408+
}
2409+
2410+
default:
2411+
throw new NotImplementedException();
2412+
}
2413+
}
2414+
23582415
public override async Task Nested_contains_with_Lists_and_no_inferred_type_mapping()
23592416
{
23602417
await base.Nested_contains_with_Lists_and_no_inferred_type_mapping();

test/EFCore.PG.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsNpgsqlTest.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,34 @@ SELECT CAST(b."DateTimeOffset" AT TIME ZONE 'UTC' AS time)
139139
""");
140140
}
141141

142+
public override async Task DateTime()
143+
{
144+
await base.DateTime();
145+
146+
AssertSql(
147+
"""
148+
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan"
149+
FROM "BasicTypesEntities" AS b
150+
WHERE b."DateTimeOffset" AT TIME ZONE 'UTC' = TIMESTAMP '1998-05-04T15:30:10'
151+
""");
152+
}
153+
154+
// The base test compares DateTimeOffset.UtcDateTime with an Unspecified DateTime, which Npgsql can't generate as a timestamptz literal
155+
public override Task UtcDateTime()
156+
=> Assert.ThrowsAsync<ArgumentException>(() => base.UtcDateTime());
157+
158+
public override async Task LocalDateTime()
159+
{
160+
await base.LocalDateTime();
161+
162+
AssertSql(
163+
"""
164+
SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan"
165+
FROM "BasicTypesEntities" AS b
166+
WHERE b."DateTimeOffset"::timestamp > TIMESTAMP '1999-01-01T00:00:00'
167+
""");
168+
}
169+
142170
public override async Task AddYears()
143171
{
144172
await base.AddYears();
@@ -222,6 +250,15 @@ public override Task ToUnixTimeMilliseconds()
222250
public override Task ToUnixTimeSecond()
223251
=> AssertTranslationFailed(() => base.ToUnixTimeSecond());
224252

253+
public override Task ToOffset()
254+
=> AssertTranslationFailed(() => base.ToOffset());
255+
256+
public override Task Ctor_DateTime()
257+
=> AssertTranslationFailed(() => base.Ctor_DateTime());
258+
259+
public override Task Ctor_DateTime_TimeSpan()
260+
=> AssertTranslationFailed(() => base.Ctor_DateTime_TimeSpan());
261+
225262
public override async Task Milliseconds_parameter_and_constant()
226263
{
227264
await base.Milliseconds_parameter_and_constant();

0 commit comments

Comments
 (0)