Example #1
0
func newSargableOr(expr *expression.Or) *sargableOr {
	rv := &sargableOr{}
	rv.test = func(expr2 expression.Expression) (bool, error) {
		for _, child := range expr.Operands() {
			if !SargableFor(child, expr2) {
				return false, nil
			}
		}

		return true, nil
	}

	return rv
}
Example #2
0
func (this *JSConverter) VisitOr(expr *expression.Or) (interface{}, error) {
	var buf bytes.Buffer
	buf.WriteString("(")

	for i, op := range expr.Operands() {
		if i > 0 {
			buf.WriteString(" || ")
		}

		buf.WriteString(this.Visit(op))
	}

	buf.WriteString(")")
	return buf.String(), nil
}
Example #3
0
func newSargOr(expr *expression.Or) *sargOr {
	rv := &sargOr{}
	rv.sarg = func(expr2 expression.Expression) (Spans, error) {
		if expr.EquivalentTo(expr2) {
			return _SELF_SPANS, nil
		}

		spans := make(Spans, 0, len(expr.Operands()))
		for _, child := range expr.Operands() {
			cspans := SargFor(child, expr2)
			if len(cspans) > 0 {
				spans = append(spans, cspans...)
			}
		}

		return spans, nil
	}

	return rv
}