Skip to content

fix/disable-switching-if-the-same-params-used#79

Merged
RamyHakam merged 1 commit intomasterfrom
fix/disable-switching-if-the-same-params-used
Feb 14, 2026
Merged

fix/disable-switching-if-the-same-params-used#79
RamyHakam merged 1 commit intomasterfrom
fix/disable-switching-if-the-same-params-used

Conversation

@RamyHakam
Copy link
Owner

This pull request enhances the tenant database switching logic to ensure that a switch only occurs when the full set of connection parameters changes, rather than just the database name. This prevents unnecessary reconnections when the configuration is unchanged and correctly handles cases where the same database name is used on different hosts. The changes also include an additional unit test to verify the new behavior.

Improvements to tenant database switching logic:

  • Changed DbSwitchEventListener to track the full set of connection parameters ($currentTenantParams) instead of only the database name, ensuring more accurate detection of when a switch is needed.
  • Updated the logic in onHakamMultiTenancyBundleEventSwitchDbEvent to skip switching only if all connection parameters match, not just the database name. [1] [2]

Testing enhancements:

  • Added a new unit test testSwitchesWhenSameDbNameButDifferentHost to verify that a switch occurs when the database name is the same but other parameters (like host) differ, ensuring correct behavior in multi-host scenarios.

@RamyHakam RamyHakam self-assigned this Feb 14, 2026
@RamyHakam RamyHakam merged commit 97f38d2 into master Feb 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant