Repository navigation
fix(export): view and EDN exports keep child rows and import back whole - #13785
Closed
yuxi-liu-wired wants to merge 3 commits into
Closed
yuxi-liu-wired wants to merge 3 commits into
yuxi-liu-wired wants to merge 3 commits into
Conversation
This was referenced Oct 16, 2026
yuxi-liu-wired
force-pushed
the
fix/edn-export-combined
branch
6 times, most recently
from
October 25, 2026 11:01
ab2a555 to
db01e23
Compare
…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/edn-export-combined
branch
from
October 26, 2026 11:01
db01e23 to
620d4eb
Compare
Contributor
Author
|
Combined into #13869 with the other PRs of this theme, to keep the number of open PRs down; the commits are unchanged there. |
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.
This PR combines #13681, #13744, which change the same files, into one branch on current master so they no longer conflict with each other. Each part is unchanged except where two of them touched the same lines.
#13681: fix(export): a view export keeps a row whose parent is also a row
Exporting the rows of a table or list view (export type
:view-nodes) drops any row whose parent block is also a row. Example: a view lists "parent" and its child block "child"; the export contains only "parent", so "child" is lost on import.Cause:
build-blocks-exportis called with:include-children? falsefor view exports, so it builds no parent-to-children map, but it still treats every block whose parent is among the exported blocks as a non-root. Such a block is then neither nested under its parent nor exported as a root.Fix: with
:include-children? falseevery given block is a root, so each row is exported once, flat, as view exports intend. Selected-node exports (:include-children? true) are unchanged.Test:
import-view-blocks-with-child-rowinlogseq.db.sqlite.export-testexports a parent and its child as view rows, checks both are in the export, imports it, validates the db and finds the child. On master it fails twice (the child is missing from the export and from the import); with the fixlogseq.db.sqlite.export-testpasses (45 tests, 191 assertions).Found by mutation testing: changing
:include-children? falsetotrueinbuild-view-nodes-exportmade no existing test fail, and the changed version exported the child.#13744: fix(export): EDN export of pages, blocks and selections imports back whole
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.