Numeric storage parameters are formatted with the current culture, so migrations emit 0,01 instead of 0.01
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 30/100
Piste de recherche
Start in src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs, at GetStorageParameters, where non-boolean and non-string values are formatted. Check the migration SQL generator tests for storage parameters and add coverage for a decimal value under a comma-decimal culture. Done means generated CREATE TABLE, CREATE INDEX, and ALTER TABLE storage parameter SQL uses a dot decimal separator; pull request #4115 is already open.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
A non-integer numeric storage parameter (double, float, decimal) is written into DDL with the current culture's decimal separator. Under sv-SE, de-DE, fr-FR and other comma cultures, HasStorageParameter("autovacuum_vacuum_scale_factor", 0.01) generates autovacuum_vacuum_scale_factor=0,01, which breaks CREATE TABLE … WITH (…) and ALTER TABLE … SET (…) (and CREATE INDEX … WITH (…), which shares the same helper): the statement fails with a syntax error.
| Model | Culture | Generated SQL |
|---|---|---|
HasStorageParameter("autovacuum_vacuum_scale_factor", 0.01) |
en-US |
…(autovacuum_vacuum_scale_factor=0.01) ✅ |
| same | sv-SE |
…(autovacuum_vacuum_scale_factor=0,01) ❌ |
Environment
- PostgreSQL 18.6 (only to confirm the error; the repro itself needs no database)
- .NET SDK 10.0.403 / runtime 10.0.14, Npgsql.EntityFrameworkCore.PostgreSQL 10.0.3, EF Core 10.0.4, Npgsql 10.0.3
- Windows 11, current culture sv-SE
Repro
using System.Globalization;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
foreach (var culture in new[] { "en-US", "sv-SE" })
{
CultureInfo.CurrentCulture = new CultureInfo(culture);
Console.WriteLine($"--- {culture} ---");
using var context = new TestContext();
var generator = context.GetService<IMigrationsSqlGenerator>();
var differ = context.GetService<IMigrationsModelDiffer>();
var model = context.GetService<IDesignTimeModel>().Model.GetRelationalModel();
var operations = differ.GetDifferences(null, model);
foreach (var command in generator.Generate(operations, context.Model))
Console.WriteLine(command.CommandText);
}
public class TestContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseNpgsql("Host=unused");
protected override void OnModelCreating(ModelBuilder modelBuilder)
=> modelBuilder.Entity<Row>().HasStorageParameter("autovacuum_vacuum_scale_factor", 0.01);
}
public class Row
{
public int Id { get; set; }
}
Output (Npgsql.EntityFrameworkCore.PostgreSQL 10.0.3):
--- en-US ---
CREATE TABLE "Row" (
"Id" integer GENERATED BY DEFAULT AS IDENTITY,
CONSTRAINT "PK_Row" PRIMARY KEY ("Id")
)
WITH (autovacuum_vacuum_scale_factor=0.01);
--- sv-SE ---
CREATE TABLE "Row" (
"Id" integer GENERATED BY DEFAULT AS IDENTITY,
CONSTRAINT "PK_Row" PRIMARY KEY ("Id")
)
WITH (autovacuum_vacuum_scale_factor=0,01);
Diffing a model with 0.2 against one with 0.01 gives, under sv-SE: ALTER TABLE "Row" SET (autovacuum_vacuum_scale_factor=0,01); (en-US: =0.01). de-DE and fr-FR produce the same 0,01.
PostgreSQL 18 rejects the sv-SE statement:
ERROR: syntax error at or near "01"
LINE 5: WITH (autovacuum_vacuum_scale_factor=0,01);
^
Source reference
GetStorageParameters formats every value other than bool and string with a plain ToString():
Its result is used by WITH (…) (emitted for both CREATE TABLE and CREATE INDEX) and by ALTER TABLE … SET (…), while other numeric DDL in the same file already uses CultureInfo.InvariantCulture (RESTART WITH, INCREMENT BY). A likely fix is Convert.ToString(a.Value, CultureInfo.InvariantCulture)! on line 2289.
(Links are to main; the code is identical in v10.0.3, L2066–L2075, and still present on hotfix/10.0.4.)
Similar to #787 (invariant culture for DateTime literals).
Workaround: pass the value as a string ("0.01"), which the generator quotes and PostgreSQL accepts.
- Langage dominant
- C#
- Étoiles
- 1.8k
- Forks
- 268
- Merge moyen
- 2 h 35 min
- PR mergées (30 j)
- 136
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de npgsql/efcore.pg
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
NTS: the M ordinate is dropped from geometry SQL literals and from geometries stored in JSONPeut-être pris @Ahmed7991 l’a pris il y a 5 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
npgsql/efcore.pg#4093 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
`TimeSpan`/`Duration` component members: negative values are floored, and intervals computed in SQL are read field by fieldPeut-être pris @jeremy-morren l’a pris il y a 11 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Les mainteneurs répondent en général sous 1 jour
-
`Contains` on a JSON primitive collection compares JSON text, so `DateTime` and `TimeOnly` items never matchPeut-être pris @Mr444-dev l’a pris il y a 7 jours. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
npgsql/efcore.pg#4099 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Array translations: chained `Skip`/`Take` return an empty array, `int.MaxValue` bounds overflow, and `Intersect().Any()` ignores NULL elementsPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de npgsql/efcore.pg
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
sebastienros/fluid#1273 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 1 jour
-
[Feature]: Add Ukrainian (Українська) as a target language for the Translator (Ollama) engineOuverteenhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
KnifeLemon/Filee#1344 ·
Les mainteneurs répondent en général sous 1 jour
-
Issue-Bug Needs-Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours