Reconcile @Upsert annotation usage with AGENTS.md and docs #13

Closed
opened 2026-06-28 09:42:32 +00:00 by admin · 1 comment
Owner

Context

AGENTS.md:302 says "Use @Upsert Room annotation for insert-or-update operations" and docs/03-function-todos.md:26 says the upsert path "Uses Room @Upsert". But:

  • RecurringExpenseDao defines only @Insert(onConflict = REPLACE) + @Update (app/src/main/java/dev/achmad/ledgerr/data/local/dao/RecurringExpenseDao.kt:37-41)
  • ExpenseDao defines only @Insert(onConflict = REPLACE) + @Update (app/src/main/java/dev/achmad/ledgerr/data/local/dao/ExpenseDao.kt:57-61)

So the interactors — UpsertExpense (PR #2), UpsertRecurringExpense and ProcessDueRecurringExpenses (PR #10) — all use a manual if (id == 0L) insert else update pattern instead of @Upsert. Both PRs shipped with this pattern; neither can call dao.upsert(...) because the method does not exist.

This is a pre-existing docs-vs-code mismatch. Pick a direction and converge.

What to do

Option A — align code with the docs (recommended):

  1. Add @Upsert methods to both ExpenseDao and RecurringExpenseDao:
    @Upsert
    suspend fun upsert(entity: ExpenseEntity): Long
    
  2. Update UpsertExpense.await and UpsertRecurringExpense.await to call dao.upsert(entity) and return the new id.
  3. ProcessDueRecurringExpenses can keep its per-row loop (it needs the per-row new id and the post-insert template update) but can call expenseDao.upsert(...) for the insert step.
  4. No doc changes needed.

Option B — relax the docs:

  1. Remove or rephrase the @Upsert line in AGENTS.md:302.
  2. Update docs/03-function-todos.md:26 to describe the actual insert/update pattern.
  3. No code changes.

Acceptance

  • Direction chosen (A or B above) and the matching change made
  • If A: ./gradlew assembleDebug succeeds
  • PRs #10, #2 still build / still match the docs after the change

Implementation rule

Per AGENTS.md — do not start implementation without explicit user sign-off on this issue. When working, check for related issues in the remote repo first.

## Context `AGENTS.md:302` says "Use `@Upsert` Room annotation for insert-or-update operations" and `docs/03-function-todos.md:26` says the upsert path "Uses Room `@Upsert`". But: - `RecurringExpenseDao` defines only `@Insert(onConflict = REPLACE)` + `@Update` (`app/src/main/java/dev/achmad/ledgerr/data/local/dao/RecurringExpenseDao.kt:37-41`) - `ExpenseDao` defines only `@Insert(onConflict = REPLACE)` + `@Update` (`app/src/main/java/dev/achmad/ledgerr/data/local/dao/ExpenseDao.kt:57-61`) So the interactors — `UpsertExpense` (PR #2), `UpsertRecurringExpense` and `ProcessDueRecurringExpenses` (PR #10) — all use a manual `if (id == 0L) insert else update` pattern instead of `@Upsert`. Both PRs shipped with this pattern; neither can call `dao.upsert(...)` because the method does not exist. This is a pre-existing docs-vs-code mismatch. Pick a direction and converge. ## What to do **Option A — align code with the docs (recommended):** 1. Add `@Upsert` methods to both `ExpenseDao` and `RecurringExpenseDao`: ```kotlin @Upsert suspend fun upsert(entity: ExpenseEntity): Long ``` 2. Update `UpsertExpense.await` and `UpsertRecurringExpense.await` to call `dao.upsert(entity)` and return the new id. 3. `ProcessDueRecurringExpenses` can keep its per-row loop (it needs the per-row new id and the post-insert template update) but can call `expenseDao.upsert(...)` for the insert step. 4. No doc changes needed. **Option B — relax the docs:** 1. Remove or rephrase the `@Upsert` line in `AGENTS.md:302`. 2. Update `docs/03-function-todos.md:26` to describe the actual `insert`/`update` pattern. 3. No code changes. ## Acceptance - [ ] Direction chosen (A or B above) and the matching change made - [ ] If A: `./gradlew assembleDebug` succeeds - [ ] PRs #10, #2 still build / still match the docs after the change ## Implementation rule Per `AGENTS.md` — do not start implementation without explicit user sign-off on this issue. When working, check for related issues in the remote repo first.
Author
Owner

Closing — addressed as a review comment on PR #10 (#10) instead of a separate issue.

Closing — addressed as a review comment on PR #10 (https://git.achmad.dev/admin/ledgerr/pulls/10) instead of a separate issue.
admin closed this issue 2026-06-28 09:44:47 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/ledgerr#13