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

Add support for filtering api responses #26

Closed
mochic opened this issue Jul 25, 2024 · 2 comments
Closed

Add support for filtering api responses #26

mochic opened this issue Jul 25, 2024 · 2 comments

Comments

@mochic
Copy link
Collaborator

mochic commented Jul 25, 2024

We currently use slims-python-api under the hood. We want to be able to add api filters beyond just equality. In my mind, we could overload a custom object or use helper functions like here: https://github.com/genohm/slims-python-api/blob/master/src/slims/criteria.py

I personally prefer the helper function approach. I think that the custom object might be a little hard to test but if that's what end users desire then I can implement the magic overloaded object ontop of the helper functions. It would allow us to do:

client.fetch_models(model_class, model_class.prop > some_value)

versus

client.fetch_models(model_class, criterion_helpers.greater_than(prop_name, some_value))

Looking to potential end users for feedback.

@bruno-f-cruz
Copy link
Collaborator

+1 for helpers. It worries that some of their calls do not immediately translate into python operators and we would need to try to find cludges for them.

My only suggestion would be to validate prop_name (and maybe some_value (?)) against model_class (i.e. does the attribute exists, and is its type compatible) before making the request. Probably at the level of the "fetch_models" method.

@mochic mochic mentioned this issue Jul 30, 2024
@mochic
Copy link
Collaborator Author

mochic commented Sep 20, 2024

Resolved in #27

@mochic mochic closed this as completed Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants