-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix issues related to importing file to db #12353
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
base: master
Are you sure you want to change the base?
Conversation
megayu
commented
Jan 26, 2026
- fix multiline block containing attributes will be truncated and lose data, content like "1\nbackground-color:: red\n2"
- fix block attribute name contains "/" will broke, now change "/" to "-", like "key/value:: 1\n1"
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.
Pull request overview
This PR fixes issues in the file-graph → DB import pipeline where (1) multi-line block content could be truncated when properties are present, and (2) property names containing / could break during import.
Changes:
- Add a regression fixture + assertions to ensure multi-line blocks with properties preserve non-property lines in
:block/title. - Normalize file relative paths before filtering
logseq/andassets/directories during import. - Sanitize property names by converting
/to-during property extraction.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| deps/graph-parser/test/resources/exporter-test-graph/journals/2024_08_07.md | Adds a multi-line block containing a property line to reproduce the truncation scenario. |
| deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs | Extends importer integration tests to assert the fixed multi-line block title behavior. |
| deps/graph-parser/src/logseq/graph_parser/exporter.cljs | Normalizes relative paths before checking logseq/ and assets/ prefixes. |
| deps/graph-parser/src/logseq/graph_parser/block.cljs | Updates property key normalization (/ → -) and adjusts title handling for blocks with properties. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| k (-> (string/lower-case k) | ||
| (string/replace "/" "-") | ||
| (string/replace " " "-") | ||
| (string/replace "_" "-"))] |
Copilot
AI
Jan 26, 2026
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.
The new property-name normalization replaces "/" with "-", but there’s no test covering this behavior. Please add a unit test (e.g., in logseq.graph-parser.block-test/test-extract-properties) asserting that an input property like "key/value" is parsed as :key-value (and ideally that refs/page-refs behave as expected).
| options' (assoc options | ||
| :remove-properties? | ||
| (and export-to-db-graph? | ||
| (and (gp-property/properties-ast? (first (get all-blocks (dec block-idx)))) | ||
| (= "Custom" (ffirst (get all-blocks (- block-idx 2))))))) | ||
| (or prev-block-custom-query? | ||
| (and prev-block-properties? (not prev-block-custom-query?))))) |
Copilot
AI
Jan 26, 2026
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.
The :remove-properties? predicate can be simplified: (or prev-block-custom-query? (and prev-block-properties? (not prev-block-custom-query?))) is equivalent to just prev-block-properties? (since prev-block-custom-query? implies prev-block-properties?). Simplifying this would also let you drop the prev-block-custom-query? local, and update the nearby comment accordingly (it currently mentions only custom queries).