You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
595 B

  1. package builder
  2. import "fmt"
  3. // Between
  4. type Between struct {
  5. Col string
  6. LessVal interface{}
  7. MoreVal interface{}
  8. }
  9. var _ Cond = Between{}
  10. func (between Between) WriteTo(w Writer) error {
  11. if _, err := fmt.Fprintf(w, "%s BETWEEN ? AND ?", between.Col); err != nil {
  12. return err
  13. }
  14. w.Append(between.LessVal, between.MoreVal)
  15. return nil
  16. }
  17. func (between Between) And(conds ...Cond) Cond {
  18. return And(between, And(conds...))
  19. }
  20. func (between Between) Or(conds ...Cond) Cond {
  21. return Or(between, Or(conds...))
  22. }
  23. func (between Between) IsValid() bool {
  24. return len(between.Col) > 0
  25. }