Repository navigation
fix(schema): refresh the schema tree after DDL (0.19.1) - #62
Merged
Merged
Conversation
The tree cached each level on first expand and never re-fetched, so a table created after its schema was expanded never appeared, and an empty level dead-ended on expand. After a DDL statement, re-introspect every loaded node still in the tree; populate() now merges into the existing children so surviving nodes keep their subtree and expansion, and a refresh doesn't pop open a collapsed node. Expanding a loaded but empty node fetches it again. Affects every driver, not just Stoolap.
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
CREATE TABLE, the new table never appeared. The empty level also couldn't be expanded again, becausedescend_or_toggledoes nothing when there are no children. A DDL statement only reloaded the autocomplete cache. Reported against Stoolap, but SQLite, Postgres and MySQL behave the same.SchemaPanel::refresh_targets). The cost is bounded by what the user has expanded.populate()now merges into the existing children. Surviving tables keep their node, with their expanded columns/indices subtree, and refreshing a collapsed node doesn't open it.Test plan
cargo fmt && cargo clippy --all-targets -- -D warnings && cargo test: 678 tests pass locally. There are 4 newSchemaPaneltests: a table created after an empty load, re-expanding an empty node, subtree and collapse state kept on refresh, and the selection moving to the parent when the selected table is dropped.stoolap::memory:schema, then ranCREATE TABLE test,CREATE TABLE otherandDROP TABLE other. The tree updated after each statement without re-expanding.sqlite:and PostgresALTER TABLE … ADD COLUMNwith the table's columns expanded. The new column should appear.