...

Source file src/github.com/doug-martin/goqu/v9/exp/range.go

Documentation: github.com/doug-martin/goqu/v9/exp

     1  package exp
     2  
     3  type (
     4  	ranged struct {
     5  		lhs Expression
     6  		rhs RangeVal
     7  		op  RangeOperation
     8  	}
     9  	rangeVal struct {
    10  		start interface{}
    11  		end   interface{}
    12  	}
    13  )
    14  
    15  // used internally to create an BETWEEN comparison RangeExpression
    16  func between(lhs Expression, rhs RangeVal) RangeExpression {
    17  	return NewRangeExpression(BetweenOp, lhs, rhs)
    18  }
    19  
    20  // used internally to create an NOT BETWEEN comparison RangeExpression
    21  func notBetween(lhs Expression, rhs RangeVal) RangeExpression {
    22  	return NewRangeExpression(NotBetweenOp, lhs, rhs)
    23  }
    24  
    25  func NewRangeExpression(op RangeOperation, lhs Expression, rhs RangeVal) RangeExpression {
    26  	return ranged{op: op, lhs: lhs, rhs: rhs}
    27  }
    28  
    29  func (r ranged) Clone() Expression {
    30  	return NewRangeExpression(r.op, r.lhs.Clone(), r.rhs)
    31  }
    32  
    33  func (r ranged) Expression() Expression {
    34  	return r
    35  }
    36  
    37  func (r ranged) RHS() RangeVal {
    38  	return r.rhs
    39  }
    40  
    41  func (r ranged) LHS() Expression {
    42  	return r.lhs
    43  }
    44  
    45  func (r ranged) Op() RangeOperation {
    46  	return r.op
    47  }
    48  
    49  // Creates a new Range to be used with a Between expression
    50  //    exp.C("col").Between(exp.Range(1, 10))
    51  func NewRangeVal(start, end interface{}) RangeVal {
    52  	return rangeVal{start: start, end: end}
    53  }
    54  
    55  func (rv rangeVal) Start() interface{} {
    56  	return rv.start
    57  }
    58  
    59  func (rv rangeVal) End() interface{} {
    60  	return rv.end
    61  }
    62  

View as plain text