github.com/octohelm/storage@v0.0.0-20240516030302-1ac2cc1ea347/pkg/sqlbuilder/addition_where.go (about)

     1  package sqlbuilder
     2  
     3  import (
     4  	"context"
     5  )
     6  
     7  func Where(c SqlExpr) Addition {
     8  	return &where{
     9  		condition: AsCond(c),
    10  	}
    11  }
    12  
    13  type where struct {
    14  	condition SqlCondition
    15  }
    16  
    17  func (*where) AdditionType() AdditionType {
    18  	return AdditionWhere
    19  }
    20  
    21  func (w *where) IsNil() bool {
    22  	return w == nil || IsNilExpr(w.condition)
    23  }
    24  
    25  func (w *where) Ex(ctx context.Context) *Ex {
    26  	e := Expr("WHERE ")
    27  	e.WriteExpr(w.condition)
    28  	return e.Ex(ctx)
    29  }