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

Consider behavior of find_one() functions in the case of multiple matches #193

Open
tnederlof opened this issue May 20, 2024 · 2 comments
Open
Labels
enhancement New feature or request question Further information is requested sdk

Comments

@tnederlof
Copy link

The find_one() function returns the first if multiple are found. It is documented in the README here:

* If more than one entity match the query, `.find_one()` returns the first

IMO it would be safer to error out on these functions, especially with endpoints that accept a prefix parameter since users may be searching with prefix, which can easily match multiple users inadvertently (Users find_one() searches username, first name, and last name for example).

@tdstein
Copy link
Collaborator

tdstein commented May 28, 2024

This behavior matches the get method signature better than the find_one method.

Currently, the existing get methods accept a unique identifier and then raise an exception if the resource isn't found. However, this is a good reason to expand the method signature for different query patterns.

If we implement this, we should consider raising a different exception for zero results and more than one result.

@tdstein tdstein added enhancement New feature or request question Further information is requested labels May 28, 2024
@tdstein tdstein added the sdk label Sep 13, 2024
@tdstein
Copy link
Collaborator

tdstein commented Sep 13, 2024

Relates to #294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested sdk
Projects
None yet
Development

No branches or pull requests

2 participants