Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RawContactRefresh, DataRawContact, and BlankRawContactToRawContact extensions could return incorrect RawContact #130

Closed
vestrel00 opened this issue Dec 5, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@vestrel00
Copy link
Owner

The following extension functions,

(Mutable)�RawContact.refresh
DataEntity.rawContact
BlankRawContact.toRawContact

could return the incorrect RawContact if the RawContact belongs to a Contact that has more than one associated RawContact.

This is due to the following code in RawContactRefresh.kt,

internal fun Contacts.findFirstRawContactWithId(...): RawContact? = 
if (rawContactId.isProfileId) {
    profile().query()
        .find(cancel)
        ?.rawContacts
        ?.find { it.id == rawContactId }
} else {
    query()
        .where(Fields.RawContact.Id equalTo rawContactId)
        .find(cancel)
        .firstOrNull()
        ?.rawContacts
        ?.firstOrNull()
}

Notice ?.rawContacts?.firstOrNull() just returns the first RawContact found instead of filtering for the ID.

@vestrel00 vestrel00 added the bug Something isn't working label Dec 5, 2021
@vestrel00 vestrel00 self-assigned this Dec 5, 2021
@vestrel00
Copy link
Owner Author

This is a part of v0.1.9 Release Checklist.

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

No branches or pull requests

1 participant