Skip to content

WL-0MM8V4UPC02YMFXK: Add non-destructive db.upsertItems() API#788

Merged
rgardler-msft merged 1 commit intomainfrom
wl-0MM8V4UPC02YMFXK-upsert-items
Mar 2, 2026
Merged

WL-0MM8V4UPC02YMFXK: Add non-destructive db.upsertItems() API#788
rgardler-msft merged 1 commit intomainfrom
wl-0MM8V4UPC02YMFXK-upsert-items

Conversation

@rgardler-msft
Copy link
Copy Markdown
Owner

Summary

  • Adds upsertItems(items, dependencyEdges?) method to WorklogDatabase that saves items via INSERT OR REPLACE without calling clearWorkItems(), preventing data loss when updating a subset of work items
  • Only upserts dependency edges whose fromId or toId belongs to the provided items set, leaving all other edges untouched
  • No-op when items array is empty (no export/sync triggered)

Work Item

WL-0MM8V4UPC02YMFXK (child of WL-0MM8RQOC902W3LM5 — Fix destructive db.import() in GitHub sync flows)

Changes

  • src/database.ts: Added upsertItems() method adjacent to existing import() method
  • tests/unit/database-upsert.test.ts: 13 unit tests covering all acceptance criteria

Testing

  • All 1204 tests pass (94 test files)
  • Build compiles cleanly with no type errors

Add upsertItems(items, dependencyEdges?) method to WorklogDatabase that
saves items via INSERT OR REPLACE without calling clearWorkItems(),
preventing data loss when updating a subset of work items.

Key behaviors:
- Iterates items calling store.saveWorkItem() (INSERT...ON CONFLICT DO UPDATE)
- Only upserts dependency edges whose fromId or toId belongs to provided items
- Calls exportToJsonl() and triggerAutoSync() exactly once after upserting
- No-op when items array is empty (no export/sync triggered)
- Existing import() method is unchanged

Includes 13 unit tests covering all acceptance criteria.
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