Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
AsaiYusuke committed Jan 18, 2021
1 parent aa026dc commit 0ca44e1
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions syntax_basic_compare_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,12 @@ func (q *syntaxBasicCompareQuery) compute(
rightValues := q.rightParam.compute(root, currentList, container)
rightFound := q.comparator.typeCast(rightValues)

if leftFound {
if leftFound && rightFound {
for leftIndex := range leftValues {
if _, ok := leftValues[leftIndex].(struct{}); ok {
continue
}

if !rightFound {
if !q.leftParam.isLiteral {
leftValues[leftIndex] = struct{}{}
}
continue
}

for rightIndex := range rightValues {
if _, ok := rightValues[rightIndex].(struct{}); ok {
continue
Expand All @@ -51,16 +44,23 @@ func (q *syntaxBasicCompareQuery) compute(
}
}
}

} else if !q.rightParam.isLiteral {
for rightIndex := range rightValues {
rightValues[rightIndex] = struct{}{}
}
}

if !q.leftParam.isLiteral {
if !rightFound {
q.setBlankValues(leftValues)
}
return leftValues
}

if !leftFound {
q.setBlankValues(rightValues)
}
return rightValues
}

func (q *syntaxBasicCompareQuery) setBlankValues(values []interface{}) {
for leftIndex := range values {
values[leftIndex] = struct{}{}
}
}

0 comments on commit 0ca44e1

Please sign in to comment.