Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: preserve page hierarchy and property links in File-to-DB imports - #13188

Open
antoniel wants to merge 2 commits into
logseq:masterfrom
antoniel:fix/file-to-db-import-hierarchy-tag-collisions-and-property-links
Open

fix: preserve page hierarchy and property links in File-to-DB imports#13188
antoniel wants to merge 2 commits into
logseq:masterfrom
antoniel:fix/file-to-db-import-hierarchy-tag-collisions-and-property-links

Conversation

@antoniel

@antoniel antoniel commented Sep 7, 2026

Copy link
Copy Markdown

Summary

Fix legacy File-to-DB imports that leave namespace pages with invalid child order or broken property references.

  • Give namespace pages child order and keep class roots out of Library.
  • Preserve built-in properties when tags collide, and preserve an existing custom tag when a later file declares a property with the same name.
  • Convert text-property page links to UUID references, including saved values when a property changes from node/date to text.
  • Report unsupported legacy template properties as ignored instead of aborting the import.
  • Finalize renderer revisions in batches of 128, yielding between batches; show finalization/validation progress and close the indicator on unexpected errors.

Related to logseq/db-test#1076. This addresses import data integrity and finalization responsiveness; it does not claim to resolve every worker reconnection failure reported there. Overlaps with #12961 on built-in tag/property collisions; this approach preserves the tag as a separate class.

Validation

  • Test compilation and bb lint:dev passed.
  • Main compiled suite (excluding dependency-specific suites, integration, long and fix-me tests): 2024 tests, 7987 assertions passed, including the 139-test worker suite.
  • Four importer regression tests: 18 assertions passed, using synthetic fixtures for namespaces, property links, collisions and leftover templates.
  • Translation validation, hardcoded-string lint and dictionary formatting passed (English and Simplified Chinese).
  • Desktop REPL confirmed that worker progress messages update renderer state.

The broader dependency run also exposed a failing logseq.graph-parser.block-test/existing-journal-reference-reuses-stored-identity-test assertion (journal display format); that parser path is unchanged by this PR. Dependency suites require their own working directories.

No schema changes or migration required; fixes apply to new imports. Batching is covered by timer-yield assertions, without an import-speed benchmark claim.

Preserve namespace ordering, tag identities and property links during File-to-DB import. Batch renderer finalization and report progress with regression coverage.
@CLAassistant

CLAassistant commented Sep 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@megayu

megayu commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

With Import all tags enabled, tags are converted into classes. If a tag has the same name as the parent page in a namespace such as father/child, converting father into a class conflicts with the DB model: a page's parent must also be a page, not a class.

I think the better way is the importer detect this conflict and explicitly report that the graph cannot be imported with the current options. It should ask the user to rename the conflicting tag, or rename the parent page and update its namespace references, or remove the child page.

Adding an order to child or keeping father out of Library does not resolve the conflict. The resulting parent–child relationship would still violate the DB model.

@antoniel

antoniel commented Sep 8, 2026

Copy link
Copy Markdown
Author

That makes sense, I agree. I’m happy to update the implementation

Should we detect these conflicts in the import modal and block the import before it starts?

My concern is that some graphs might have thousands of these cases. Could we offer a bulk fix, like renaming conflicting tags to father-tag, or changing father/child to father-child and updating the references?

What approach would you prefer? I can adjust the PR accordingly

Keep the current import lifecycle and class/property handling while preserving the remaining exporter fixes and regression tests.
@megayu

megayu commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

In fact, there is one more scenario that can also lead to the same issue, for example, both of these inputs conflict with the DB model:

  • category/child together with #category when Import all tags is enabled, because category would be converted into a class.
  • category/child together with a category:: value property declaration, because category would be converted into a property.

In the DB model, the parent of a page must also be a page.

I think we better give the choice to the user, and the importer should detect the conflict before importing, stop the import, and ask the user to resolve the source data. The message should identify the conflicting namespace parent and explain the available options:

  • Rename the conflicting tag or property.
  • Rename the namespace parent and update its references.
  • Rename or remove the child page.
  • For tag conflicts, disable Import all tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants