Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise default PG compat version to 14 #2937

Merged
merged 1 commit into from
Nov 13, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class NpgsqlOptionsExtension : RelationalOptionsExtension
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public static readonly Version DefaultPostgresVersion = new(12, 0);
public static readonly Version DefaultPostgresVersion = new(14, 0);

/// <summary>
/// The backend version to target.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public NpgsqlMemberTranslatorProvider(
: base(dependencies)
{
var npgsqlOptions = contextOptions.FindExtension<NpgsqlOptionsExtension>() ?? new();
var supportsMultiranges = !npgsqlOptions.IsPostgresVersionSet
|| npgsqlOptions.IsPostgresVersionSet && npgsqlOptions.PostgresVersion.AtLeast(14);
var supportsMultiranges = npgsqlOptions.PostgresVersion.AtLeast(14);

var sqlExpressionFactory = (NpgsqlSqlExpressionFactory)dependencies.SqlExpressionFactory;
JsonPocoTranslator = new NpgsqlJsonPocoTranslator(typeMappingSource, sqlExpressionFactory, model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public NpgsqlMethodCallTranslatorProvider(
: base(dependencies)
{
var npgsqlOptions = contextOptions.FindExtension<NpgsqlOptionsExtension>() ?? new();
var supportsMultiranges = !npgsqlOptions.IsPostgresVersionSet
|| npgsqlOptions.IsPostgresVersionSet && npgsqlOptions.PostgresVersion.AtLeast(14);
var supportsMultiranges = npgsqlOptions.PostgresVersion.AtLeast(14);

var sqlExpressionFactory = (NpgsqlSqlExpressionFactory)dependencies.SqlExpressionFactory;
var typeMappingSource = (NpgsqlTypeMappingSource)dependencies.RelationalTypeMappingSource;
Expand Down
4 changes: 1 addition & 3 deletions src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ public NpgsqlTypeMappingSource(
INpgsqlSingletonOptions options)
: base(dependencies, relationalDependencies)
{
_supportsMultiranges = !options.IsPostgresVersionSet
|| options.IsPostgresVersionSet && options.PostgresVersion.AtLeast(14);

_supportsMultiranges = options.PostgresVersion.AtLeast(14);
_sqlGenerationHelper = Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));

// Initialize range mappings, which reference on other mappings
Expand Down
6 changes: 4 additions & 2 deletions test/EFCore.PG.FunctionalTests/DefaultValuesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public ChipsContext(IServiceProvider serviceProvider, string databaseName)

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseNpgsql(NpgsqlTestStore.CreateConnectionString(_databaseName))
.UseNpgsql(
NpgsqlTestStore.CreateConnectionString(_databaseName),
o => o.SetPostgresVersion(TestEnvironment.PostgresVersion))
.UseInternalServiceProvider(_serviceProvider);

protected override void OnModelCreating(ModelBuilder modelBuilder)
Expand All @@ -73,4 +75,4 @@ private class KettleChips
public string Name { get; set; }
public DateTime BestBuyDate { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,17 @@ public override MigrationsContext CreateContext()
new DbContextOptionsBuilder()
.UseNpgsql(TestStore.ConnectionString, b => b.ApplyConfiguration()
.CommandTimeout(NpgsqlTestStore.CommandTimeout)
.SetPostgresVersion(TestEnvironment.PostgresVersion)
.ReverseNullOrdering()))
.UseInternalServiceProvider(ServiceProvider)
.UseInternalServiceProvider(CreateServiceProvider())
.Options;
return new MigrationsContext(options);
}

private static IServiceProvider CreateServiceProvider()
=> new ServiceCollection()
.AddEntityFrameworkNpgsql()
.BuildServiceProvider();
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/EFCore.PG.FunctionalTests/SpatialNpgsqlFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
{
var optionsBuilder = base.AddOptions(builder);
new NpgsqlDbContextOptionsBuilder(optionsBuilder).UseNetTopologySuite();
new NpgsqlDbContextOptionsBuilder(optionsBuilder)
.UseNetTopologySuite()
.SetPostgresVersion(TestEnvironment.PostgresVersion);

return optionsBuilder;
}
Expand Down
Loading