Repository navigation
fix(export): EDN export of pages, blocks and selections imports back whole - #13744
Closed
yuxi-liu-wired wants to merge 2 commits into
Closed
yuxi-liu-wired wants to merge 2 commits into
yuxi-liu-wired wants to merge 2 commits into
Conversation
…whole - Selected nodes: a selected block that another selected block references was exported a second time; blocks already in the export are no longer added as referenced blocks. - A node property value on a nested block pointing at a page outside the export failed the import (No uuid for page): sqlite.build now looks at nested blocks when it creates pages from property values. - A referenced block is exported with its title, so the refs in that title are followed too; before, they imported as raw uuids.
…rty value; follow refs in many node values With the selected block no longer exported twice, a selected block that is another selected block's node value lost the uuid the value points at (build-export: uuids are not defined). Such a node now keeps its uuid. Property values with many values (sets) were skipped when collecting the blocks whose title refs are followed.
yuxi-liu-wired
force-pushed
the
fix/export-selected-nodes-refs
branch
from
October 16, 2026 18:36
ec5a75d to
d9ef318
Compare
Contributor
Author
|
Combined with the other PRs that change the same files into #13785. |
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.
Three ways an EDN export of a page, a block or a selection did not import back whole. Found by fuzzing export → import for every export type (
:graphand:graph-humancame back with no mismatch).1. A selected block that another selected block references is exported twice
Selecting
alphaandxwherexhas a node propertysource:: alpha(or a[[uuid]]ref toalpha) exportsalphatwice on the same page: once as a selected node, once as a referenced block (build-uuid-block-export). The import creates a duplicate, or merges the two copies by uuid and the page's block order changes.build-page-exportavoids this by dropping its own page;build-selected-nodes-exportandbuild-view-nodes-exportpassed nothing.Fix:
build-uuid-block-exporttakes the nodes already in the export (:exported-nodes) and leaves them out. An exported node that is another node's property value keeps its uuid (:include-uuid-fnincludes the property value entities), so the value still resolves.2. A node property value on a nested block fails the import
A child block with
source:: [[Alpha]], where pageAlphais not otherwise in the export: the export writes[:build/page {:block/title "Alpha"}]and relies onsqlite.build/add-new-pages-from-propertiesto create the page, butget-used-properties-from-optionsreads only each page's top-level:blocks, never:build/children, so the import throwsNo uuid for page '{:block/title "Alpha"}'. The same block at the top level imports fine.Fix:
get-used-properties-from-optionsalso walks:build/children.3. A ref inside a referenced block imports as a raw uuid
Exporting a block
export [[middle]]wheremiddleismiddle [[Beta]]:middleis exported (shallow) with its title, butBetais not, so the import showsmiddle [[<uuid>]].Fix:
build-content-ref-exportfollows refs in the titles of referenced blocks until no new ones turn up. The blocks it starts from include every value of a many node property (a set), not only single values.Tests
In
logseq.db.sqlite.export-test:import-selected-nodes-that-reference-each-other,import-selected-nodes-where-one-is-a-node-value-of-another,import-page-with-node-value-on-child-block,import-block-with-refs-two-levels-deep,import-block-with-node-value-whose-title-has-a-ref. Each fails or errors on master and passes with the fix; the other export tests pass.The EDN export → import fuzzer (every export type, seeds 1 and 11) finds no mismatch with this PR. The text loops' remaining cases are logseq/db-test#1442.