-
Notifications
You must be signed in to change notification settings - Fork 495
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
Support for getting values from maps #70
Comments
That approach is probably the best to get you unstuck for now, yeah. There's no technical drawback to it - I hadn't added map support yet because I'd preferred to have map keys be specified by braces (like Either way, the nuts and bolts of your implementation is pretty close to what I would have done to support maps! Chaining the return value from multiple accessor function calls is on the top of my list for working on the library. |
got it, thanks! |
Support nested Parameters by adding a type assertion to the query loop in evaluationStage.go. Remove the check for unexported accessors in the parser, and replace with a check for unexported field access in evaluationStage. This allows nesting maps in an arbitrary fashion with the MapParameters type, as shown by the unit test. Fixes Knetic#70
So I've been going around in circles, trying to make Knetic work with more complex expressions where you have to chain multiple calls.
My initial attempt was to use:
I guess my question is - given how accessors are implemented, would it make sense to add basic support for maps?
E.g. you could probably support syntax like "User.Attributes.attr_name" (not ideal, but better than nothing) by inserting a code here which uses reflection to check if it's a map (instead of a struct), and get the corresponding value:
govaluate/evaluationStage.go
Line 283 in 93a54c2
Do you see any drawbacks to this approach?
I'm trying to figure how I can move forward with Knect instead of starting to write my own expression parser...
The text was updated successfully, but these errors were encountered: