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
11 changes: 5 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<EFCoreVersion>11.0.0</EFCoreVersion>
<MicrosoftExtensionsVersion>11.0.0</MicrosoftExtensionsVersion>
<MicrosoftExtensionsConfigurationVersion>11.0.0</MicrosoftExtensionsConfigurationVersion>
<NpgsqlVersion>10.0.3</NpgsqlVersion>
<NpgsqlVersion>11.0.0</NpgsqlVersion>
<XunitVersion>4.0.1</XunitVersion>
</PropertyGroup>

Expand All @@ -25,14 +25,13 @@
<PackageVersion Include="Npgsql" Version="$(NpgsqlVersion)" />
<PackageVersion Include="Npgsql.NodaTime" Version="$(NpgsqlVersion)" />
<PackageVersion Include="Npgsql.NetTopologySuite" Version="$(NpgsqlVersion)" />
<PackageVersion Include="Npgsql.DependencyInjection" Version="$(NpgsqlVersion)" />

<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.403" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageVersion Include="Microsoft.DotNet.XUnitV3Extensions" Version="11.0.0-beta.26526.3" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="11.0.100" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageVersion Include="Microsoft.DotNet.XUnitV3Extensions" Version="11.0.0-beta.26569.5" />
<PackageVersion Include="xunit.v3" Version="$(XunitVersion)" />
<PackageVersion Include="xunit.v3.runner.inproc.console" Version="$(XunitVersion)" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.1" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.16.0" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.17.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Microsoft.Extensions.DependencyInjection;
/// Provides extension methods to configure Entity Framework Core for Npgsql.
/// </summary>
// ReSharper disable once UnusedMember.Global
public static class NpgsqlServiceCollectionExtensions
public static class NpgsqlEntityFrameworkServiceCollectionExtensions
Comment thread
roji marked this conversation as resolved.
Resolved
{
/// <summary>
/// <para>
Expand Down
3 changes: 1 addition & 2 deletions src/EFCore.PG/Storage/Internal/NpgsqlRelationalConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ public virtual INpgsqlRelationalConnection CreateAdminConnection()
var adminConnectionString = new NpgsqlConnectionStringBuilder(ConnectionString)
{
Database = npgsqlOptions.AdminDatabase ?? "postgres",
Pooling = false,
Multiplexing = false
Pooling = false
}.ToString();

// Cloned connections must be owned so disposing the wrapper also closes and disposes them.
Expand Down
2 changes: 1 addition & 1 deletion test/EFCore.PG.FunctionalTests/NpgsqlApiConsistencyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class NpgsqlApiConsistencyFixture : ApiConsistencyFixtureBase
typeof(NpgsqlModelBuilderExtensions),
typeof(NpgsqlPropertyBuilderExtensions),
typeof(NpgsqlEntityTypeBuilderExtensions),
typeof(NpgsqlServiceCollectionExtensions)
typeof(NpgsqlEntityFrameworkServiceCollectionExtensions)
];

public override HashSet<MethodInfo> UnmatchedMetadataMethods { get; } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;

// Cannot write DateTime with Kind=Unspecified to PostgreSQL type 'timestamp with time zone', only UTC is supported.
public override Task Query_generates_correct_datetime2_parameter_definition(int? fractionalSeconds, string postfix)
=> Assert.ThrowsAsync<ArgumentException>(
() => base.Query_generates_correct_datetime2_parameter_definition(fractionalSeconds, postfix));
public override async Task Query_generates_correct_datetime2_parameter_definition(int? fractionalSeconds, string postfix)
=> Assert.IsType<ArgumentException>((await Assert.ThrowsAsync<InvalidCastException>(
() => base.Query_generates_correct_datetime2_parameter_definition(fractionalSeconds, postfix))).InnerException);

// Cannot write DateTimeOffset with Offset=10:00:00 to PostgreSQL type 'timestamp with time zone', only offset 0 (UTC) is supported.
public override Task Query_generates_correct_datetimeoffset_parameter_definition(int? fractionalSeconds, string postfix)
=> Assert.ThrowsAsync<ArgumentException>(
() => base.Query_generates_correct_datetime2_parameter_definition(fractionalSeconds, postfix));
public override async Task Query_generates_correct_datetimeoffset_parameter_definition(int? fractionalSeconds, string postfix)
=> Assert.IsType<ArgumentException>((await Assert.ThrowsAsync<InvalidCastException>(
() => base.Query_generates_correct_datetimeoffset_parameter_definition(fractionalSeconds, postfix))).InnerException);

// Cannot write DateTimeOffset with Offset=10:00:00 to PostgreSQL type 'timestamp with time zone', only offset 0 (UTC) is supported.
public override Task Projecting_one_of_two_similar_complex_types_picks_the_correct_one()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,11 @@ public override Task Parse_with_constant()

// DateTime.Parse() returns either a Local or Unspecified DateTime, which can't be compared with timestamptz
// (see TemporalTranslationsNpgsqlTimestampWithoutTimeZoneTest for a working version of this test)
public override Task Parse_with_parameter()
=> Assert.ThrowsAsync<ArgumentException>(() => base.Parse_with_parameter());
public override async Task Parse_with_parameter()
{
var exception = await Assert.ThrowsAsync<InvalidCastException>(() => base.Parse_with_parameter());
Assert.IsType<ArgumentException>(exception.InnerException);
}

public override async Task New_with_constant()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task Cannot_insert_utc_datetime_into_timestamp()

ctx.Entities.Add(new Entity { TimestampDateTime = DateTime.UtcNow });
var exception = await Assert.ThrowsAsync<DbUpdateException>(() => ctx.SaveChangesAsync());
Assert.IsType<ArgumentException>(exception.InnerException);
Assert.IsType<ArgumentException>(Assert.IsType<InvalidCastException>(exception.InnerException).InnerException);
}

[ConditionalFact]
Expand All @@ -69,7 +69,7 @@ public async Task Cannot_insert_unspecified_datetime_into_timestamptz()

ctx.Entities.Add(new Entity { TimestamptzDateTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Unspecified) });
var exception = await Assert.ThrowsAsync<DbUpdateException>(() => ctx.SaveChangesAsync());
Assert.IsType<ArgumentException>(exception.InnerException);
Assert.IsType<ArgumentException>(Assert.IsType<InvalidCastException>(exception.InnerException).InnerException);
}

[ConditionalFact]
Expand All @@ -79,7 +79,7 @@ public async Task Cannot_insert_local_datetime_into_timestamptz()

ctx.Entities.Add(new Entity { TimestamptzDateTime = DateTime.Now });
var exception = await Assert.ThrowsAsync<DbUpdateException>(() => ctx.SaveChangesAsync());
Assert.IsType<ArgumentException>(exception.InnerException);
Assert.IsType<ArgumentException>(Assert.IsType<InvalidCastException>(exception.InnerException).InnerException);
}

#endregion Basic mapping
Expand Down Expand Up @@ -163,9 +163,10 @@ public async Task Cannot_compare_timestamp_column_to_utc_DateTime_parameter()

var dateTime = new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Utc);

await Assert.ThrowsAsync<ArgumentException>(
var exception = await Assert.ThrowsAsync<InvalidCastException>(
() => ctx.Entities.Where(e => e.TimestampDateTime == dateTime)
.ToListAsync());
Assert.IsType<ArgumentException>(exception.InnerException);
}

[ConditionalTheory]
Expand Down Expand Up @@ -221,9 +222,10 @@ public async Task Cannot_compare_timestamptz_column_to_local_DateTime_parameter(

var dateTime = new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Local);

await Assert.ThrowsAsync<ArgumentException>(
var exception = await Assert.ThrowsAsync<InvalidCastException>(
() => ctx.Entities.Where(e => e.TimestamptzDateTime == dateTime)
.ToListAsync());
Assert.IsType<ArgumentException>(exception.InnerException);
}

[ConditionalFact]
Expand All @@ -243,9 +245,10 @@ public async Task Cannot_compare_timestamptz_column_to_unspecified_DateTime_para

var dateTime = new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Unspecified);

await Assert.ThrowsAsync<ArgumentException>(
var exception = await Assert.ThrowsAsync<InvalidCastException>(
() => ctx.Entities.Where(e => e.TimestamptzDateTime == dateTime)
.ToListAsync());
Assert.IsType<ArgumentException>(exception.InnerException);
}

[ConditionalFact]
Expand Down
1 change: 0 additions & 1 deletion test/EFCore.PG.Tests/EFCore.PG.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Npgsql.DependencyInjection" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions test/EFCore.PG.Tests/NpgsqlRelationalConnectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void Can_create_master_connection_with_connection_string()
using var master = connection.CreateAdminConnection();

Assert.Equal(
@"Host=localhost;Database=postgres;Username=some_user;Password=some_password;Pooling=False;Multiplexing=False",
@"Host=localhost;Database=postgres;Username=some_user;Password=some_password;Pooling=False",
master.ConnectionString);
}

Expand All @@ -338,7 +338,7 @@ public void Can_create_master_connection_with_connection_string_and_alternate_ad
using var master = connection.CreateAdminConnection();

Assert.Equal(
@"Host=localhost;Database=template0;Username=some_user;Password=some_password;Pooling=False;Multiplexing=False",
@"Host=localhost;Database=template0;Username=some_user;Password=some_password;Pooling=False",
master.ConnectionString);
}

Expand Down
Loading