Esempio n. 1
0
func newSargAnd(expr *expression.And) *sargAnd {
	rv := &sargAnd{}
	rv.sarg = func(expr2 expression.Expression) (spans Spans, err error) {
		if expr.EquivalentTo(expr2) {
			return _SELF_SPANS, nil
		}

		for _, op := range expr.Operands() {
			s := SargFor(op, expr2)
			if s == nil {
				continue
			}

			if spans == nil {
				spans = s
			} else {
				spans = constrain(spans, s)
			}
		}

		return
	}

	return rv
}
Esempio n. 2
0
func newSubsetAnd(expr *expression.And) *subsetAnd {
	rv := &subsetAnd{}
	rv.test = func(expr2 expression.Expression) (bool, error) {
		for _, child := range expr.Operands() {
			if SubsetOf(child, expr2) {
				return true, nil
			}
		}

		return false, nil
	}

	return rv
}
Esempio n. 3
0
func (this *JSConverter) VisitAnd(expr *expression.And) (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
}