-
Notifications
You must be signed in to change notification settings - Fork 110
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
More convenient way to implement raw/custom operators #338
Comments
Makes sense. |
Thanks! I'm happy with this so I'll close the issue :) |
Actually, reopening this. I've cloned the wiki and added documentation about I'm not sure how easy it is to get wiki changes upstreamed, but this gist suggests a workflow at least: https://gist.github.com/omaraboumrad/35654da0a376c57a2e0ab4d92ad0c339#core-contributors Let me know if you have feedback on the docs. |
Merged. 👍 |
Thanks! With that I'll consider this issue well addressed. :) |
Problem
When we want to call a function that Jet doesn't support natively, we can use
jet.Func("funcname", SomeExpression, ...)
. This is convenient; only the function name needs to be a hardcoded string, while the arguments can be any Jet expression. Jet will take care of serializing the expressions to SQL.However, if we want to use an operator that Jet doesn't support, say for example
ILIKE
(aka.~~*
) in postgres, then we have to resort tojet.Raw
, which is not nearly as convenient: we have to serialize the operands ourselves in some way. Expressions that are actual columns are easy enough, we can just saysomeColumn.Name()
and put that into the raw string, but if it's a more complex expression I don't see an obvious way of doing it.Proposed solution
I see that internally Jet does have a function that does almost exactly what I'd like:
NewBinaryOperatorExpression(lhs Serializer, rhs Serializer, operator string)
. If the public API exposed a wrapper around this, something likejet.BinaryOperator(lhs jet.Expression, rhs jet.Expression, operator string) jet.Expression
then I could do things like this to implement my own operators:The text was updated successfully, but these errors were encountered: