Skip to content
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

fix issue#89 #126 #134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions evaluationStage.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ func (this *evaluationStage) isShortCircuitable() bool {
}

func noopStageRight(left interface{}, right interface{}, parameters Parameters) (interface{}, error) {
return right, nil
switch right.(type) {
case separatorArr:
return right.(separatorArr).arr, nil
case []interface{}:
return []interface{}{right}, nil
default:
return right, nil
}
}

func addStage(left interface{}, right interface{}, parameters Parameters) (interface{}, error) {
Expand Down Expand Up @@ -404,18 +411,20 @@ func makeAccessorStage(pair []string) evaluationOperator {
}
}

func separatorStage(left interface{}, right interface{}, parameters Parameters) (interface{}, error) {

var ret []interface{}
// to differentiate between arrays passed as parameters, and an array made with separators
type separatorArr struct {
arr []interface{}
}

func separatorStage(left interface{}, right interface{}, parameters Parameters) (interface{}, error) {
switch left.(type) {
case []interface{}:
ret = append(left.([]interface{}), right)
case separatorArr:
leftArr := left.(separatorArr)
leftArr.arr = append(leftArr.arr, right)
return leftArr, nil
default:
ret = []interface{}{left, right}
return separatorArr{arr:[]interface{}{left, right}}, nil
}

return ret, nil
}

func inStage(left interface{}, right interface{}, parameters Parameters) (interface{}, error) {
Expand Down