Skip to content

Conversation

@rfc2822
Copy link
Member

@rfc2822 rfc2822 commented Sep 6, 2025

Fixes batch event insertion with back-references when the inserted event is not the first in the batch.

  • Added a new test testAddEvent_toBatch_AsSecondOperation in AndroidCalendarTest.kt to verify that events can be inserted as the second operation in a batch and that back-references are handled correctly.
  • Changed addEvent in AndroidCalendar to use batch.nextBackrefIdx() when adding an event, ensuring that sub-values (such as reminders) correctly reference the newly inserted event row, regardless of its position in the batch.

- Modify `addEvent` method in `AndroidCalendar` to use the correct back-reference index for event rows.
- Update `withValueBackReference` function to include documentation about proper usage.
@rfc2822 rfc2822 self-assigned this Sep 6, 2025
@rfc2822 rfc2822 added the bug Something isn't working label Sep 6, 2025
@rfc2822 rfc2822 requested a review from Copilot September 6, 2025 10:38
@rfc2822 rfc2822 marked this pull request as ready for review September 6, 2025 10:38
Copy link
Contributor

Copilot AI left a 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 a bug in batch event insertion where back-references to newly inserted events were incorrectly hardcoded to index 0, causing issues when the event wasn't the first operation in the batch.

  • Changed addEvent to use batch.nextBackrefIdx() instead of hardcoded index 0 for back-references
  • Added comprehensive test coverage for batch operations where the event insertion is not the first operation
  • Updated comments to improve clarity around event row insertion and data row references

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
AndroidCalendar.kt Fixed back-reference index calculation and improved comment clarity
BatchOperation.kt Added documentation for the withValueBackReference method
AndroidCalendarTest.kt Added test case for event insertion as second batch operation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rfc2822 rfc2822 merged commit 3f79c2c into main Sep 6, 2025
11 checks passed
@rfc2822 rfc2822 deleted the 58-androidcalendaraddevent-assumes-that-it-always-writes-the-first-event-of-a-batch branch September 6, 2025 10:40
@github-project-automation github-project-automation bot moved this from Todo to Done in DAVx⁵ Releases Sep 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

AndroidCalendar.addEvent() assumes that it always writes the first event of a batch

1 participant