-
Notifications
You must be signed in to change notification settings - Fork 54
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
projection is returning more fields than expected #94
Comments
This is indeed only the case in Android. It's kind of expected behavior which I am currently looking into if it can be worked around. Allow me to explain: On iOS one can simply indicate the projection with unique keys, and the iOS system will only retrieve and return those fields specified in the projection. In Android this works pretty similar. However, as it turns out, these projection keys are not necessarily unique. For example That means that if you query the This can be worked around of course. There are a few ways: Provide a selection matching the projection. This means that we will indicate to Android inside the query that we only want to retrieve specific types of MIMETYPES. I actually already tried this before and it's now commented out in the code: https://github.com/capacitor-community/contacts/blob/main/android/src/main/java/getcapacitor/community/contacts/Contacts.java#L144 The disadvantage of this, is that it will only retrieve contacts that match your projection. For example if your projection only specifies We could do two separate queries. One where we follow the solution mentioned above. And then also one where we query all the remaining contacts, but then only request the This solution seems pretty neat to me. However, I'm not sure if it's actually faster than just doing it the way we're doing it now. If it's not faster, it kinda defeats the purpose of That being said however, I don't think for most use-cases this imperfection in the plugin will actually effect the performance significantly. But please let me know if you have experienced otherwise. |
I have a PR for this: #97 Ran a bunch of benchmarks, but couldn't really find a significant performance difference between the current implementation and the two alternatives. So I'll probably just end up implementing it like this because of consistency with the docs and the iOS counterpart. If you would like to share your opinion about this; please do! |
Describe the bug
According to the docs here, if we use:
It will only return two properties: contactId and name. This is not what is happening, I am receiving more fields, phones.
Example:
The same thing is happening with the
pickContact()
method. Example:Platforms
iOS seems to be fine, but maybe you can re-validate the issue on iOS to be sure is not happening.
To Reproduce
Steps to reproduce the behavior:
getContacts()
method with a projection with only namepickContact()
method with a projection with only nameExpected behavior
Contacts should have only a name object, no more than that.
Example:
Screenshots
None.
Smartphone (please complete the following information):
Additional context
None.
The text was updated successfully, but these errors were encountered: