Repository navigation
fix(database): keep entered values when switching connection mode - #45872
Open
sadpandajoe wants to merge 2 commits into
Open
sadpandajoe wants to merge 2 commits into
sadpandajoe wants to merge 2 commits into
Conversation
Switching between the dynamic form and the SQLAlchemy URI form in the database modal replaces the whole form state, discarding typed values. Add tests that fill each form, toggle to the other and back, and assert the typed values are still present.
Switching between the dynamic form and the SQLAlchemy URI form in the database modal replaced the whole form state with the three keys sent by the toggle buttons, discarding every typed value (and the engine metadata the form relies on). Merge the toggle payload onto the previous state instead, falling back to the previous database name and engine when the payload leaves them undefined.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45872 +/- ##
=======================================
Coverage 65.62% 65.62%
=======================================
Files 3069 3069
Lines 205661 205663 +2
Branches 48336 48338 +2
=======================================
+ Hits 134956 134965 +9
+ Misses 67624 67617 -7
Partials 3081 3081
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sadpandajoe
marked this pull request as ready for review
October 30, 2026 02:24
Contributor
This branch has not been deployed
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.
SUMMARY
In the "Connect a database" modal, switching between the dynamic form and "Connect this database with a SQLAlchemy URI string instead" (and back) discarded everything the user had entered: host, port, database, username, password, a typed SQLAlchemy URI, and the engine metadata the form relies on (for example which Advanced options are offered). Only the display name survived, so a long password or a pasted URI had to be entered again with no warning.
Root Cause
The reducer case that handles the mode switch (
ActionType.ConfigMethodChangeindbReducer) returned only the keys sent by the two toggle buttons (engine,configuration_method,database_name), replacing the entire modal state instead of merging into it. That is why the display name, which the buttons copy by hand, was the only value that survived. The replace semantics date from when the case shared a branch with the engine-selection action, where starting from a blank form was correct; once the toggle became reachable from a populated form, nothing exercised it.The case now merges the payload onto the previous state, falling back to the previous
database_nameandengineif the payload leaves them undefined. The two toggle buttons are unchanged.Stale values that remain in state cannot reach the saved database: on create and update the backend builds
sqlalchemy_urifromparametersonly whenconfiguration_methodisdynamic_form(overwriting any existing URI), and ignoresparametersotherwise.Not addressed here
Switching from the dynamic form to the URI form still does not fill in the SQLAlchemy URI from the values typed so far. Nothing on the client builds a URI from
parameters, and no API returns one without creating or updating the database, so this needs backend support and is left for a separate change.BEFORE/AFTER SCREENSHOTS
Before video: https://gist.githubusercontent.com/sadpandajoe/ed885611403e98253fe4bdbde8526b4f/raw/298709d02d5b28fd57f6c603fc8daf33c6d53aff/before.mp4
After video: https://gist.githubusercontent.com/sadpandajoe/ed885611403e98253fe4bdbde8526b4f/raw/298709d02d5b28fd57f6c603fc8daf33c6d53aff/after.mp4
TESTING INSTRUCTIONS
Automated:
Four new tests fail on the parent commit and pass with this change: two that drive the real modal (dynamic form values and a typed URI each survive a round trip between the two modes) and two reducer tests for
ConfigMethodChange(previous fields preserved with the newconfiguration_methodapplied; fallback to the previousdatabase_nameandengine).Manual:
ADDITIONAL INFORMATION