...

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

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

     1  package exp
     2  
     3  type (
     4  	literal struct {
     5  		literal string
     6  		args    []interface{}
     7  	}
     8  )
     9  
    10  // Creates a new SQL literal with the provided arguments.
    11  //   L("a = 1") -> a = 1
    12  // You can also you placeholders. All placeholders within a Literal are represented by '?'
    13  //   L("a = ?", "b") -> a = 'b'
    14  // Literals can also contain placeholders for other expressions
    15  //   L("(? AND ?) OR (?)", I("a").Eq(1), I("b").Eq("b"), I("c").In([]string{"a", "b", "c"}))
    16  func NewLiteralExpression(sql string, args ...interface{}) LiteralExpression {
    17  	return literal{literal: sql, args: args}
    18  }
    19  
    20  // Returns a literal for the '*' operator
    21  func Star() LiteralExpression {
    22  	return NewLiteralExpression("*")
    23  }
    24  
    25  // Returns a literal for the 'DEFAULT'
    26  func Default() LiteralExpression {
    27  	return NewLiteralExpression("DEFAULT")
    28  }
    29  
    30  func (l literal) Clone() Expression {
    31  	return NewLiteralExpression(l.literal, l.args...)
    32  }
    33  
    34  func (l literal) Literal() string {
    35  	return l.literal
    36  }
    37  
    38  func (l literal) Args() []interface{} {
    39  	return l.args
    40  }
    41  
    42  func (l literal) Expression() Expression                           { return l }
    43  func (l literal) As(val interface{}) AliasedExpression             { return NewAliasExpression(l, val) }
    44  func (l literal) Eq(val interface{}) BooleanExpression             { return eq(l, val) }
    45  func (l literal) Neq(val interface{}) BooleanExpression            { return neq(l, val) }
    46  func (l literal) Gt(val interface{}) BooleanExpression             { return gt(l, val) }
    47  func (l literal) Gte(val interface{}) BooleanExpression            { return gte(l, val) }
    48  func (l literal) Lt(val interface{}) BooleanExpression             { return lt(l, val) }
    49  func (l literal) Lte(val interface{}) BooleanExpression            { return lte(l, val) }
    50  func (l literal) Asc() OrderedExpression                           { return asc(l) }
    51  func (l literal) Desc() OrderedExpression                          { return desc(l) }
    52  func (l literal) Between(val RangeVal) RangeExpression             { return between(l, val) }
    53  func (l literal) NotBetween(val RangeVal) RangeExpression          { return notBetween(l, val) }
    54  func (l literal) Like(val interface{}) BooleanExpression           { return like(l, val) }
    55  func (l literal) NotLike(val interface{}) BooleanExpression        { return notLike(l, val) }
    56  func (l literal) ILike(val interface{}) BooleanExpression          { return iLike(l, val) }
    57  func (l literal) NotILike(val interface{}) BooleanExpression       { return notILike(l, val) }
    58  func (l literal) RegexpLike(val interface{}) BooleanExpression     { return regexpLike(l, val) }
    59  func (l literal) RegexpNotLike(val interface{}) BooleanExpression  { return regexpNotLike(l, val) }
    60  func (l literal) RegexpILike(val interface{}) BooleanExpression    { return regexpILike(l, val) }
    61  func (l literal) RegexpNotILike(val interface{}) BooleanExpression { return regexpNotILike(l, val) }
    62  func (l literal) In(vals ...interface{}) BooleanExpression         { return in(l, vals...) }
    63  func (l literal) NotIn(vals ...interface{}) BooleanExpression      { return notIn(l, vals...) }
    64  func (l literal) Is(val interface{}) BooleanExpression             { return is(l, val) }
    65  func (l literal) IsNot(val interface{}) BooleanExpression          { return isNot(l, val) }
    66  func (l literal) IsNull() BooleanExpression                        { return is(l, nil) }
    67  func (l literal) IsNotNull() BooleanExpression                     { return isNot(l, nil) }
    68  func (l literal) IsTrue() BooleanExpression                        { return is(l, true) }
    69  func (l literal) IsNotTrue() BooleanExpression                     { return isNot(l, true) }
    70  func (l literal) IsFalse() BooleanExpression                       { return is(l, false) }
    71  func (l literal) IsNotFalse() BooleanExpression                    { return isNot(l, false) }
    72  
    73  func (l literal) BitwiseInversion() BitwiseExpression                { return bitwiseInversion(l) }
    74  func (l literal) BitwiseOr(val interface{}) BitwiseExpression        { return bitwiseOr(l, val) }
    75  func (l literal) BitwiseAnd(val interface{}) BitwiseExpression       { return bitwiseAnd(l, val) }
    76  func (l literal) BitwiseXor(val interface{}) BitwiseExpression       { return bitwiseXor(l, val) }
    77  func (l literal) BitwiseLeftShift(val interface{}) BitwiseExpression { return bitwiseLeftShift(l, val) }
    78  func (l literal) BitwiseRightShift(val interface{}) BitwiseExpression {
    79  	return bitwiseRightShift(l, val)
    80  }
    81  

View as plain text