Repository navigation
fix: a table without a schema is compared in the schema the database puts it in - #133
Merged
Merged
Conversation
…puts it in NameClaims compared a table without a schema and one in public as two schemas, so no SK1001 was raised and the migration failed at apply with 42P07. The dialect now names the schema the database puts an unqualified table in (ISchemaDialect.DefaultSchema): public for PostgreSQL, null for the kernel's own dialect, which does not guess. Closes #100 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #100
Problem
In a model without a default schema, a table without a schema claimed its names in schema
null, and a table mapped withToTable("x", "public")in schemapublic.NameClaimscompared the two as text, so an exclusion constraint onrole_grantsand an EF Core index of the same name onpublic.bookingsraised noSK1001, and the migration failed at apply with 42P07: on a stock PostgreSQL database both tables are inpublic.Change
ISchemaDialect.DefaultSchema(new, under the experimental contract): the schema the database puts an object in when its statement names none, or null when the dialect does not know it. The docs say what asearch_paththat points elsewhere means: a database the model does not describe.SchemaDialect.DefaultSchemais null. The kernel does not guess for a provider without a package (dboon SQL Server comes with SqlServerIndex: clustered and nonclustered, typed #29; SQLite has one namespace per database). With null, a table without a schema shares a namespace only with another table without one, as before.NpgsqlSchemaDialect.DefaultSchemaispublic.NameClaims.Samecompares schemas under the dialect's default. A model's ownHasDefaultSchemastill arrives through the relational model, as before.CLAUDE.md: one line under "The planner", one under "The PostgreSQL package".Tests
NameClaimTests:A_table_without_a_schema_is_in_public_when_the_model_sets_none: the scenario from the issue is refused withSK1001.A_table_without_a_schema_is_not_in_another_named_one: the reverse case. The table without a schema against one inopscollides with nothing.The_dialect_puts_a_table_without_a_schema_in_public.Integration/NameClaimLiveTests:The_server_refuses_a_name_taken_in_public_for_a_table_created_without_a_schema: 42P07.The_server_takes_a_name_taken_in_another_schema_for_a_table_created_without_one.Migrations/NameClaimTests:Without_a_providers_rule_a_table_without_a_schema_is_in_no_named_oneon Npgsql and SQL Server. SQLite has no schemas to put a table in.The_kernels_dialect_knows_no_default_schemaon all three providers.I broke each rule in a scratch copy (rsync without
.git,bin,obj) and ran the suites:NameClaimscomparing schemas as text again,A_table_without_a_schema_is_in_public_when_the_model_sets_nonefails.NpgsqlSchemaDialect.DefaultSchemanull,A_table_without_a_schema_is_in_public_when_the_model_sets_noneandThe_dialect_puts_a_table_without_a_schema_in_publicfail.public,Without_a_providers_rule_a_table_without_a_schema_is_in_no_named_onefails (Npgsql and SqlServer), and so doesThe_kernels_dialect_knows_no_default_schema(all three providers).Every suite passes:
SchemaKit.ApiProbes: 125 testsdotnet build CodoMetis.EFCore.SchemaKit.slnxhas no warning.Decisions in this PR that are not confirmed
ISchemaDialect. The interface is underSK9001until rc.1, so adding to it is allowed. A dialect outside the repository that implements the interface directly instead of deriving fromSchemaDialectwill no longer compile.publicstands for. It is the stock server's answer, not the answer of the session that applies the migration. The planner does not readsearch_pathat diff time, since a diff has no connection.NameComparisonsays otherwise.CHANGELOG.mdfor the preview.🤖 Generated with Claude Code