Skip to content

Conversation

ArnyminerZ
Copy link
Member

Purpose

See #1659. Events.DIRTY can be null, but we are not correctly handling it with NOT dirty.

Short description

  • Extended condition from NOT dirty TO (dirty is NULL OR dirty=0)
  • Improved tests to verify this behavior.

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

@ArnyminerZ ArnyminerZ self-assigned this Aug 14, 2025
@ArnyminerZ ArnyminerZ added the bug Something isn't working label Aug 14, 2025
@ArnyminerZ ArnyminerZ linked an issue Aug 14, 2025 that may be closed by this pull request
@ArnyminerZ ArnyminerZ marked this pull request as ready for review August 14, 2025 15:49
@ArnyminerZ ArnyminerZ requested a review from Copilot August 14, 2025 15:49
Copilot

This comment was marked as outdated.

@ArnyminerZ ArnyminerZ requested a review from sunkup August 14, 2025 16:10
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat. I think that should do it 👍 Since the queries are longer now I'd prefer to have them indented, but not sure if @rfc2822 agrees, so feel free to leave it like that.

Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I like that the expression is always in parentheses. We should also write all SQL keywords like IS NULL in upper-case. If there's mixed case, it could cause the impression that is NULL and IS NULL is something different.

Did you check whether Events.DIRTY is used somewhere else where this problem may occur, including in the synctools library?

@sunkup
Copy link
Member

sunkup commented Aug 19, 2025

Thanks for indenting 👍

Did you check whether Events.DIRTY is used somewhere else where this problem may occur, including in the synctools library?

Took a quick look. We could mention it here:

  • kdoc of LocalCollection.markNotDirty()
  • kdoc of LocalCollection.removeNotDirtyMarked()

I don't think there are other places, but better check yourself too. Synctools looks okay.

@ArnyminerZ ArnyminerZ requested a review from rfc2822 August 19, 2025 12:06
@ArnyminerZ
Copy link
Member Author

Improved kdoc and used capital letters

@sunkup
Copy link
Member

sunkup commented Aug 19, 2025

Ah dammit. I just realise LocalCollection is generic and markNotDirty() and removeNotDirtyMarked() are also used by task lists and address books, so we should probably ubdate the whole kdoc in a generic way and not speak about events at all (maybe just in the override kdoc?).

@ArnyminerZ
Copy link
Member Author

Yeah... the kdoc currently for LocalCollection's markNotDirty and removeNotDirtyMarked is specific for events. We should find a way to make it either generic, or ignore it completely and expect overrides to add it.

However, for example, LocalAddressBook.removeNotDirtyMarked already doesn't say anything. So I'd set it to something more generic...

@ArnyminerZ
Copy link
Member Author

The issue is that there's RawContacts.DIRTY, Events.DIRTY, then Jtx has its own flag; tasks has _DIRTY.... So its hard to reference it in a "generic" manner. Maybe we should just write it down somehow in plain text

@sunkup sunkup marked this pull request as draft August 19, 2025 14:47
@sunkup
Copy link
Member

sunkup commented Aug 20, 2025

Exactly. I would provide a generic plain text description in the interface and override the generic kdoc by adding kdoc to the implementations. There we can mention Events.DIRTY and RawContacts.DIRTY, etc respectively. Can you add that?

@rfc2822
Copy link
Member

rfc2822 commented Aug 20, 2025

If it's only about the KDoc: or just "the dirty flag of the respective provider"?

@ArnyminerZ ArnyminerZ requested a review from sunkup August 23, 2025 09:50
@ArnyminerZ ArnyminerZ marked this pull request as ready for review August 23, 2025 09:50
Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments about tests

@ArnyminerZ ArnyminerZ requested review from rfc2822 and Copilot August 25, 2025 17:43
Copy link
Contributor

@Copilot 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 the handling of null values for the Events.DIRTY field by updating SQL WHERE clauses to properly check for both null and 0 values when identifying "not dirty" events.

  • Updated SQL conditions from NOT dirty to (dirty IS NULL OR dirty=0) in both markNotDirty and removeNotDirtyMarked methods
  • Added comprehensive test coverage for both dirty=0 and dirty=null scenarios
  • Updated documentation to reflect the more accurate behavior description

Reviewed Changes

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

File Description
LocalCollection.kt Updated interface documentation to remove specific implementation details about dirty field handling
LocalCalendar.kt Fixed SQL WHERE clauses to properly handle null dirty values in addition to 0 values
LocalCalendarTest.kt Added comprehensive test cases to verify correct handling of both dirty=0 and dirty=null scenarios

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

Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me

@rfc2822
Copy link
Member

rfc2822 commented Aug 27, 2025

(So ready to merge @ArnyminerZ :))

@ArnyminerZ ArnyminerZ merged commit cd72547 into main-ose Aug 28, 2025
8 checks passed
@ArnyminerZ ArnyminerZ deleted the 1659-eventsdirty-can-be-null branch August 28, 2025 09:25
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
None yet
Development

Successfully merging this pull request may close these issues.

Events.DIRTY can be null
3 participants