Fix master-table multi-tenancy on SqlServer (DB-agnostic tenant SQL); bump 6.4.3 (#3023)#3024
Merged
Merged
Conversation
… bump 6.4.3 (GH-3023) The shared tenant-registry queries in MessageDatabase<T> (used by both the Postgres and SqlServer message stores) were written with PostgreSQL-only SQL, so UseMasterTableTenancy() failed entirely on SqlServer with "Invalid column name 'false'" during multi-tenanted resource setup: - `where {disabled} = false` / `= true` — SqlServer has no boolean literal, so it parses false/true as column names. Now a bool parameter (@disabled), which the driver maps to boolean/bit (matching the existing SetTenantDisabledAsync pattern). - AddTenantRecordAsync used `... values (..., false) on conflict (...) do update ...` — ON CONFLICT is PostgreSQL-only. Now the portable delete-then-insert already used by SeedDatabasesAsync, with a bool parameter. Also registers MasterTenantSource as IDynamicTenantSource<string> in the SqlServer provider — parity with the PostgreSQL gap closed in GH-3016 — so store-agnostic admin consumers can drive the dynamic-tenancy lifecycle on SqlServer too. Tests: SqlServer dynamic-tenant lifecycle round-trip (add/read/disable/enable/re-add/remove) + DI registration; mirrored Postgres lifecycle test (regression). Verified: master-table EfCore multi-tenancy now 16/16 on SqlServer (was 16/16 fail) and still 16/16 on Postgres; full wolverine.slnx Release build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 8, 2026
Merged
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 #3023. Found during the persistence/EF-Core compliance survey.
The bug
UseMasterTableTenancy()was completely broken on SqlServer —EfCoreTests.MultiTenancy.multi_tenancy_with_master_table_approach_sqlserverfailed 16/16 (incl.can_build_a_db_context_at_all) withSqlException: Invalid column name 'false'during multi-tenanted resource setup.The shared tenant-registry queries in
MessageDatabase<T>(Wolverine.RDBMS/MessageDatabase.Tenants.cs, used by both the Postgres and SqlServer stores) were written with PostgreSQL-only SQL:where {disabled} = false/= true— SqlServer has no boolean literal, so it parsesfalse/trueas column names.AddTenantRecordAsync:insert ... values (..., false) on conflict (...) do update ...—ON CONFLICTis PostgreSQL-only (plus the samefalse).(The
shared-databaseandstatic-connection-stringsSqlServer variants pass — this is specific to the master-table path. Postgres passes because it accepts all of the above.)The fix
@disabled), which the driver maps toboolean/bit— matching the existingSetTenantDisabledAsyncpattern.ON CONFLICTupsert → the portable delete-then-insert already used bySeedDatabasesAsync.MasterTenantSourceasIDynamicTenantSource<string>in the SqlServer provider — parity with the Postgres gap closed in Register MasterTenantSource as IDynamicTenantSource<string> in DI when UseMasterTableTenancy is configured #3016 (it had the same omission), so store-agnostic admin consumers can drive the lifecycle on SqlServer too.Tests
master_table_tenancy_dynamic_lifecycle: DI registration + a full lifecycle round-trip (add → refresh/read → disable → list-disabled → enable → re-add upsert → remove) — exercises all three fixed statements.Verification (Postgres + SqlServer both up)
multi_tenancy_with_master_table_approach_sqlserver: 16/16 pass (was 16/16 fail).multi_tenancy_with_master_table_approach_postgresql: 16/16 pass (no regression).wolverine.slnxRelease build clean (0/0).Bumps to 6.4.3.
🤖 Generated with Claude Code