hashicorp / hashicorp/go-bexpr
Selector comparison not working
- Dominant language
- Go
- Stars
- 123
- Forks
- 17
- Avg merge
- 7h 36m
- Merged PRs (30d)
- 3
Description
Hi,
Using two selectors in comparison expression doesn't seem to work.
This works:
```
"value.nomad == test and value.consul == test",
```
This doesn't:
```
"value.nomad == value.consul",
```
The following code shows the problem:
```
package main
import (
"fmt"
"os"
"github.com/hashicorp/go-bexpr"
"github.com/hashicorp/go-bexpr/grammar"
)
type Example struct {
Nomad string `bexpr:"nomad"`
Consul string `bexpr:"consul"`
}
func main() {
value := map[string]Example{
"value": {Nomad: "prueba", Consul: "prueba"},
}
expressions := []string{
"value.nomad == prueba and value.consul == prueba",
"value.nomad == value.consul",
}
for _, expression := range expressions {
eval, err := bexpr.CreateEvaluator(expression)
if err != nil {
fmt.Printf("Failed to create evaluator for expression %q: %v\n", expression, err)
continue
}
result, err := eval.Evaluate(value)
if err != nil {
fmt.Printf("Failed to run evaluation of expression %q: %v\n", expression, err)
continue
}
fmt.Printf("Result of expression %q evaluation: %t\n", expression, result)
}
}
```
I guess this is not implemented. Is there any way I can get this working? Thanks
Contributor guide
Assessment
This issue has not been assessed yet.