Skip to content

Commit

Permalink
Raise default PG compat version to 14 (#2937)
Browse files Browse the repository at this point in the history
Closes #1645
  • Loading branch information
roji authored Nov 13, 2023
1 parent ec877ca commit a173de7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
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

0 comments on commit a173de7

Please sign in to comment.