@@ -22,13 +22,10 @@ import (
2222// contain metadata such as column type and if a value is specifically a NULL value.
2323//
2424// Use it directly as an Option to expr.Compile()
25- var ValueGetter = func () expr.Option {
26- vPatcher := patcher {}
27- return func (c * conf.Config ) {
28- c .Visitors = append (c .Visitors , vPatcher )
29- getValueFunc (c )
30- }
31- }()
25+ var ValueGetter = expr .Option (func (c * conf.Config ) {
26+ c .Visitors = append (c .Visitors , patcher {})
27+ getValueFunc (c )
28+ })
3229
3330// A AnyValuer provides a generic function for a custom type to return standard go values.
3431// It allows for returning a `nil` value but does not provide any type checking at expression compile.
@@ -136,21 +133,17 @@ var supportedInterfaces = []reflect.Type{
136133type patcher struct {}
137134
138135func (patcher ) Visit (node * ast.Node ) {
139- id , ok := (* node ).(* ast.IdentifierNode )
140- if ! ok {
141- return
142- }
143-
144- nodeType := id .Type ()
145-
146- for _ , t := range supportedInterfaces {
147- if nodeType .Implements (t ) {
148- callnode := & ast.CallNode {
149- Callee : & ast.IdentifierNode {Value : "$patcher_value_getter" },
150- Arguments : []ast.Node {id },
136+ switch id := (* node ).(type ) {
137+ case * ast.IdentifierNode , * ast.MemberNode :
138+ nodeType := id .Type ()
139+ for _ , t := range supportedInterfaces {
140+ if nodeType .Implements (t ) {
141+ ast .Patch (node , & ast.CallNode {
142+ Callee : & ast.IdentifierNode {Value : "$patcher_value_getter" },
143+ Arguments : []ast.Node {id },
144+ })
145+ return
151146 }
152-
153- ast .Patch (node , callnode )
154147 }
155148 }
156149}
0 commit comments