From f7fb0161de48b05e12f357e347e00fc741b960ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gro=C3=9F?= Date: Sat, 5 Sep 2026 10:07:14 +0200 Subject: [PATCH 1/6] fix: reject names past the provider's identifier limit; open 5.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A complex index, exclusion constraint, temporal constraint or temporal foreign key whose resolved name exceeds the provider's identifier limit now fails at `migrations add`. PostgreSQL truncates such a name to 63 bytes with a NOTICE and applies the migration cleanly, so the object exists under a name that neither the declaration nor a later constraint-violation error reports; a slice dispatching on the constraint name falls through in silence. SQL Server rejects the statement at apply time instead. Both are caught here. The limit comes from EF's GetMaxIdentifierLength() (63 on PostgreSQL, 128 on SQL Server, none on SQLite), measured the way the provider measures it: characters in the core, UTF-8 bytes in the PostgreSQL satellite (MeasureIdentifier). Default names are checked too — this package never truncates them, unlike EF's own — and only the target model is validated, so a snapshot carrying such a name stays diffable. The test model for temporal foreign keys was the first to hit it: its default FK name, built from two table names, is 66 bytes. Shortened the dependent table; the changelog says to name such constraints, since a name-only change renames in place. Also bumps the version to 5.2.0, the package-validation baseline to 5.1.0 and SECURITY.md's supported line. Co-Authored-By: Claude Fable 5.1 --- CHANGELOG.md | 9 + Directory.Build.props | 4 +- README.md | 5 +- SECURITY.md | 4 +- .../CHANGELOG.md | 9 + ...NpgsqlComplexIndexMigrationsModelDiffer.cs | 27 ++- src/EFCore.ComplexIndexes/CHANGELOG.md | 7 + .../CustomMigrationsModelDiffer.cs | 55 +++++ src/EFCore.ComplexIndexes/README.md | 5 +- .../IdentifierLengthTests.cs | 217 ++++++++++++++++++ .../NpgsqlTemporalForeignKeyDifferTests.cs | 16 +- 11 files changed, 341 insertions(+), 17 deletions(-) create mode 100644 test/EFCore.ComplexIndexes.Tests/IdentifierLengthTests.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e21e8a..001ac73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ covering only what changed for that package: [PostgreSQL](src/EFCore.ComplexIndexes.PostgreSQL/CHANGELOG.md), [SQL Server](src/EFCore.ComplexIndexes.SqlServer/CHANGELOG.md). +## 5.2.0 + +The features AuditOffice's review of its own workarounds asked for, in the order they pay off: +a validation for a failure that reports nothing, a read model so an application can check its +own obligations, filters that resolve property paths the way index parts already do, an amend +API, and typed filter predicates. + +- **Changed:** an index or constraint name longer than the provider's identifier limit is rejected at `dotnet ef migrations add`. PostgreSQL truncates a name past 63 bytes with a NOTICE and applies the migration cleanly, so the index exists under a name that neither the declaration nor a later constraint-violation error reports — a slice dispatching on the constraint name falls through in silence; SQL Server rejects the statement at apply time instead. Explicit and default names alike are checked, measured the way the provider measures them (bytes on PostgreSQL, characters on SQL Server), on the target model only. The names this package derives are never truncated, unlike EF Core's own default names, so a long table name plus a long column path reaches the limit quietly, and a default temporal foreign key name, built from two table names, is the first to. Give the declaration a name; a name-only change renames in place. + ## 5.1.0 Small enhancements around the two seams, plus the silent failures found while planning the next diff --git a/Directory.Build.props b/Directory.Build.props index 74808d4..24a0302 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 5.1.0 + 5.2.0 CaffeinatedCoder MIT true @@ -63,7 +63,7 @@ --> true - 5.0.3 + 5.1.0