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.

47 lines
861 B

  1. package builder
  2. import "fmt"
  3. // IsNull
  4. type IsNull [1]string
  5. var _ Cond = IsNull{""}
  6. func (isNull IsNull) WriteTo(w Writer) error {
  7. _, err := fmt.Fprintf(w, "%s IS NULL", isNull[0])
  8. return err
  9. }
  10. func (isNull IsNull) And(conds ...Cond) Cond {
  11. return And(isNull, And(conds...))
  12. }
  13. func (isNull IsNull) Or(conds ...Cond) Cond {
  14. return Or(isNull, Or(conds...))
  15. }
  16. func (isNull IsNull) IsValid() bool {
  17. return len(isNull[0]) > 0
  18. }
  19. // NotNull
  20. type NotNull [1]string
  21. var _ Cond = NotNull{""}
  22. func (notNull NotNull) WriteTo(w Writer) error {
  23. _, err := fmt.Fprintf(w, "%s IS NOT NULL", notNull[0])
  24. return err
  25. }
  26. func (notNull NotNull) And(conds ...Cond) Cond {
  27. return And(notNull, And(conds...))
  28. }
  29. func (notNull NotNull) Or(conds ...Cond) Cond {
  30. return Or(notNull, Or(conds...))
  31. }
  32. func (notNull NotNull) IsValid() bool {
  33. return len(notNull[0]) > 0
  34. }