New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(hierarchy): should update :block/namespace
while renaming page
#8266
Conversation
…2001/logseq into fix/rename-update-namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Yes, the document is missing 👀
We have test for db model but fine to leave it to future
|
new-namespace? (text/namespace-page? new-name) | ||
update-namespace! (fn [] (let [namespace (first (gp-util/split-last "/" new-name))] | ||
(when namespace | ||
(create! namespace {:redirect? false}) ;; create parent page if not exist, creation of namespace ref is handled in `create!` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Need @tiensonqin to have a confirm as it's about DB ops
@situ2001 Tests that are using the test-helper |
…ogseq#8266) * fix: should update `block:namespace` while renaming * fix: check logic in `rename-update-namespace!` Co-authored-by: Bad3r <bad3r@protonmail.com> Co-authored-by: Junyi Du <junyidu.cn@gmail.com>
…ogseq#8266) * fix: should update `block:namespace` while renaming * fix: check logic in `rename-update-namespace!` Co-authored-by: Bad3r <bad3r@protonmail.com> Co-authored-by: Junyi Du <junyidu.cn@gmail.com>
close #8253
Because renaming the namespace page is happened from top to bottom of the hierarchy, it is very straightforward to add a function that updates
:block/namespace
of a block to its parent block or removes:block/namespace
of a block. If there is no parent block, the code invokescreate!
to create it, for example, renamingaa
toaa/bb/cc/dd
will automatically createaa
,aa/bb
,aa/bb/cc
if not exist.BTW, there is currently no description for the namespace in logseq doc so I can't get full or correct understanding of how renaming a namespace page work.
The behavior of renaming the namespace block is summarized that changing the name of a namespace page, the name of the page, and its sub-namespace page will be changed.
Imagine there are some pages.
Changing from
1/3
->1/4
will causeOther situation
aa/bb
->aabb
will remove:block/namespace
of this page.tony
->cat/tony
will add:block/namespace
of this page tocat
. Ifcat
does not exist,cat
page will be created.I have no idea where to write the test for this fix(or maybe a feature?) because I didn't find the test that simulates an env that has DataScript DB.
This is my first time contributing to the codes that involve to DataScript DB transactions. Please review it carefully. Thanks.