Skip to content

fix: correct the storage parameter comment and pin invariant formatting (#97) - #109

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
fix/97-storage-parameter-culture
Oct 20, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
fix/97-storage-parameter-culture

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #97

Problem

HasStorageParameter("x", 0.25) on a column-only complex index renders through Npgsql's stock generator, which formats numbers with the current culture. Probed against Npgsql 10.0.0:

Culture Rendered
en-US WITH (x=0.25)
de-DE, tr-TR WITH (x=0,25)
ar-SA WITH (x=0٫25)

PostgreSQL 18 rejects WITH (fillfactor=0,25) with syntax error at or near "25", so this is a loud failure, not a wrong value. The package's own generator (expression and NULLS-ordered indexes) renders invariantly. Its comment ("Mirrors Npgsql's own formatting: … numbers invariant") was wrong about the stock path.

Change

  • NpgsqlComplexIndexSqlGenerator.FormatStorageParameter: the comment now says what Npgsql does and what this generator does differently. The code is unchanged.
  • docs/postgresql-indexes.md: pass a fractional storage parameter as a string, HasStorageParameter("x", "0.25"). Both generators render it as x='0.25', and PostgreSQL reads a quoted reloption as the number (checked on 18: fillfactor='70' and autovacuum_vacuum_scale_factor='0.25' are stored as 70 and 0.25).
  • Changelog: one ### Fixed Docs line in the root and PostgreSQL changelogs.

Decision: fractional values are not forwarded as invariant strings.

  • No built-in index access method takes a fractional storage parameter: btree, hash, gist, spgist, gin and brin take integers, booleans or buffering.
  • The failure is loud: a syntax error at apply, never a different value.
  • Rewriting the value in the differ would change the annotation type written into new migrations, and existing migrations would still carry the double.
  • Npgsql's own HasIndex(…).HasStorageParameter has the same behaviour, so the fix belongs upstream, where both paths share it. I found no existing upstream issue. Filing one on npgsql/efcore.pg is left to the maintainer.

Tests

  • NpgsqlStorageParameterTests.Fractional_storage_parameter_is_culture_invariant (de-DE, tr-TR, ar-SA): this package's generator renders WITH (x=0.25). With FormatStorageParameter switched to CurrentCulture, all three rows fail.
  • The upstream behaviour is deliberately not pinned in a test. A test asserting Npgsql's bug would fail on the Dependabot bump that fixes it.
  • Full suite, integration included: 401 passed.

🤖 Generated with Claude Code

The custom generator's comment said it mirrored Npgsql's formatting with
numbers invariant. Npgsql's generator (10.0.0) formats storage parameters
with the current culture: a fractional value on a column-only index renders
x=0,25 under de-DE and tr-TR and x=0٫25 under ar-SA, which PostgreSQL
rejects with a syntax error. The comment now says so, the PostgreSQL index
guide says to pass a fractional value as a string ('0.25' is accepted),
and a test pins this package's own generator to invariant formatting under
de-DE, tr-TR and ar-SA; formatting with the current culture fails all three.

Fractional values are not rewritten to strings on the stock path: no
built-in index access method takes a fractional storage parameter, the
failure is loud, and existing migrations would keep the culture-sensitive
value anyway.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working severity/low Cosmetic, message or documentation-level difference package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL area/indexes Complex-property, composite, unique and filtered indexes labels Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 85f2b11 into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/97-storage-parameter-culture branch October 20, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/indexes Complex-property, composite, unique and filtered indexes bug Something isn't working package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL severity/low Cosmetic, message or documentation-level difference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fractional index storage parameters render with the current culture on the stock Npgsql path

1 participant