Motivation & Problem
In #630, restoreLastSelectedObject() was added to MainScreenWorkspaceState to allow returning to the last open table/view when switching back from server overview/stats.
Currently, restoreLastSelectedObject() evaluates cached object references in a static sequential order:
if (lastSelectedPostgresObject != null) { ... }
if (lastSelectedMysqlObject != null) { ... }
if (lastSelectedSqliteObject != null) { ... }
if (lastSelectedExtensionObject != null) { ... }
If lastSelectedPostgresObject was previously set and the active connection is later switched to another engine without clearing or under custom state manipulation, it evaluates Postgres first and could invoke selectPostgresObject() with a non-Postgres connection.
Proposed Scope
- In
MainScreenWorkspaceState.restoreLastSelectedObject():
- Branch on
activeConnection.type.toLowerCase():
'postgres' / 'postgresql': restore lastSelectedPostgresObject
'mysql': restore lastSelectedMysqlObject
'sqlite': restore lastSelectedSqliteObject
- default / extensions: restore
lastSelectedExtensionObject
- In
selectPostgresObject, selectMysqlObject, selectSqliteObject, selectExtensionObject:
- Clear cached object references belonging to other driver types when setting a new active object.
- Add unit tests in
main_screen_workspace_state_test.dart verifying that restoreLastSelectedObject() restores only objects matching the active connection's driver type.
Acceptance Criteria
Motivation & Problem
In #630,
restoreLastSelectedObject()was added toMainScreenWorkspaceStateto allow returning to the last open table/view when switching back from server overview/stats.Currently,
restoreLastSelectedObject()evaluates cached object references in a static sequential order:If
lastSelectedPostgresObjectwas previously set and the active connection is later switched to another engine without clearing or under custom state manipulation, it evaluates Postgres first and could invokeselectPostgresObject()with a non-Postgres connection.Proposed Scope
MainScreenWorkspaceState.restoreLastSelectedObject():activeConnection.type.toLowerCase():'postgres'/'postgresql': restorelastSelectedPostgresObject'mysql': restorelastSelectedMysqlObject'sqlite': restorelastSelectedSqliteObjectlastSelectedExtensionObjectselectPostgresObject,selectMysqlObject,selectSqliteObject,selectExtensionObject:main_screen_workspace_state_test.dartverifying thatrestoreLastSelectedObject()restores only objects matching the active connection's driver type.Acceptance Criteria
restoreLastSelectedObject()restores only the object matching the active connection's driver type.restoreLastSelectedObject()ignores cached objects belonging to different drivers.