-
Notifications
You must be signed in to change notification settings - Fork 301
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 user defined operators #590
Conversation
In general, this seems like a reasonable feature request to me.
Yeah, this does seem like a lot of pass-throughs for no real benefit. (But I'm happy that the filtering code seems "blissfully unaware" to you, that was a design goal!) Perhaps just create a simple def register_operator(name, function):
OPERATORS[name] = function in In your geographic oriented use case, did you create a new operator or did you override an existing one? Was it important that the operator was model-dependent? Thanks for your contribution! |
I was going to say I'm dubious about I can foresee maaaaybe wanting to scope operators to only be useable in certain APIs, as opposed to globally, but that seems like a niche enough use-case that |
The one other question I have is around arity. The most basic implementation of this would just assume that all user defined operators are binary. A couple more sophisticated options:
any thoughts on this? I think I'm leaning towards option 1 above, it seems not too hard to implement and a substantial improvement. |
I would start with the simplest implementation first, just |
that sounds good! i am pretty busy tomorrow, but i will try to do this over the weekend or next week |
Pull request #620 has a simpler version of this with documentation. Please add any comments there. |
Hi! Thank you for this project, I used it a while back to good effect. One thing I ran that wasn't supported out of the box was extending searching with "custom" operators. In my case, I was using PostGIS and geoalchemy, and needed to be able to query the API using geographic regions. I ended up hacking extra operators in using something like:
This patch extends the project to support this sort of thing on a per-model basis via a
custom_operators
keyword argument tocreate_api_blueprint
.Is this something you'd be interested in having? No worries if not, just figured I'd throw it out there ^_^
This PR is mostly just to demonstrate that it's possible. I have no illusions that this is the best implementation, passing
custom_operators
all over the place was just the quickest way to make it work since the filtering code right now is blissfully unaware of the existence ofAPIBase
, etc. I am happy to work up a better implementation if desired!in any case, my definite TODOs if you'd like me to move forward with this are:
let me know, cheers!