Пример #1
0
func newSargLE(expr *expression.LE) *sargLE {
	rv := &sargLE{}
	rv.sarg = func(expr2 expression.Expression) (Spans, error) {
		if expr.EquivalentTo(expr2) {
			return _SELF_SPANS, nil
		}

		var exprs expression.Expressions
		span := &Span{}

		if expr.First().EquivalentTo(expr2) {
			exprs = expression.Expressions{expr.Second().Static()}
			span.Range.High = exprs
			span.Range.Inclusion = datastore.HIGH
		} else if expr.Second().EquivalentTo(expr2) {
			exprs = expression.Expressions{expr.First().Static()}
			span.Range.Low = exprs
			span.Range.Inclusion = datastore.LOW
		}

		if len(exprs) == 0 {
			return nil, nil
		}

		return Spans{span}, nil
	}

	return rv
}
Пример #2
0
func (this *JSConverter) VisitLE(expr *expression.LE) (interface{}, error) {
	var buf bytes.Buffer
	buf.WriteString("(")
	buf.WriteString(this.Visit(expr.First()))
	buf.WriteString(" <= ")
	buf.WriteString(this.Visit(expr.Second()))
	buf.WriteString(")")
	return buf.String(), nil
}
Пример #3
0
func (this *subsetLT) VisitLE(expr *expression.LE) (interface{}, error) {
	if this.lt.First().EquivalentTo(expr.First()) {
		return LessThanOrEquals(this.lt.Second(), expr.Second()), nil
	}

	if this.lt.Second().EquivalentTo(expr.Second()) {
		return LessThanOrEquals(expr.First(), this.lt.First()), nil
	}

	return false, nil
}