Skip to content

Fix/flat database option#72

Merged
Myastr0 merged 2 commits intomasterfrom
fix/flat-database-option
Dec 14, 2025
Merged

Fix/flat database option#72
Myastr0 merged 2 commits intomasterfrom
fix/flat-database-option

Conversation

@Myastr0
Copy link
Owner

@Myastr0 Myastr0 commented Dec 14, 2025

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you lint your code locally before submission?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

Description

This PR fixes a bug in the --flat database synchronization feature where child pages were incorrectly assumed to always be created under parent pages, even when the parent object was a database.

What Changed

  • Modified synchronizeChildNode method signature: Changed from accepting parentPageId: string to accepting both parentObjectId: string and parentObjectType: ObjectType
  • Updated method calls: All calls to synchronizeChildNode now pass the correct parent object type (either 'page' or 'database') instead of hardcoding 'page'
  • Fixed parent object type propagation: When creating child pages, the method now correctly identifies whether the parent is a page or database and passes this information through the recursive call chain

Why This Change Was Needed

When using the --flat option with database synchronization, all markdown files become direct children of the database. However, the previous implementation hardcoded parentObjectType: 'page' when creating child pages, which caused issues when:

  1. The root object is a database (not a page)
  2. Child pages need to be created directly under the database
  3. The recursive synchronization needs to maintain the correct parent object type context

This fix ensures that when syncing with --flat to a database, child pages are correctly created as database items rather than attempting to create them as sub-pages of a non-existent parent page.

Technical Details

The key changes are in synchronize-markdown-to-notion.feature.ts:

  1. Line 251-252: Updated the initial call to synchronizeChildNode to pass parentObjectType based on whether rootPageElement exists (indicating a page parent) or not (indicating a database parent)

  2. Lines 437-448: Updated the synchronizeChildNode method signature to accept parentObjectId and parentObjectType instead of just parentPageId

  3. Lines 472-476: Updated the createPage call to use the passed parentObjectType instead of hardcoding 'page'

  4. Lines 495-498: Updated recursive calls to maintain the correct parent type (always 'page' for grandchildren since they're created under pages, not databases)

Testing

  • Manual testing with --flat option on database destination
  • Manual testing with --flat option on page destination
  • Manual testing without --flat option (existing behavior should remain unchanged)
  • Verify that nested pages are created correctly in both scenarios

@Myastr0
Copy link
Owner Author

Myastr0 commented Dec 14, 2025

👋 Hi, Myastr0! Thanks for opening a PR. We will review it soon.
If you have any questions, feel free to join the #need-help channel on the Discord server

@Myastr0 Myastr0 merged commit d8be78b into master Dec 14, 2025
3 checks passed
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.

1 participant