本站源代码
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.

60 lines
1.4KB

  1. // Copyright 2016 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package builder
  5. import "fmt"
  6. // IsNull defines IS NULL condition
  7. type IsNull [1]string
  8. var _ Cond = IsNull{""}
  9. // WriteTo write SQL to Writer
  10. func (isNull IsNull) WriteTo(w Writer) error {
  11. _, err := fmt.Fprintf(w, "%s IS NULL", isNull[0])
  12. return err
  13. }
  14. // And implements And with other conditions
  15. func (isNull IsNull) And(conds ...Cond) Cond {
  16. return And(isNull, And(conds...))
  17. }
  18. // Or implements Or with other conditions
  19. func (isNull IsNull) Or(conds ...Cond) Cond {
  20. return Or(isNull, Or(conds...))
  21. }
  22. // IsValid tests if this condition is valid
  23. func (isNull IsNull) IsValid() bool {
  24. return len(isNull[0]) > 0
  25. }
  26. // NotNull defines NOT NULL condition
  27. type NotNull [1]string
  28. var _ Cond = NotNull{""}
  29. // WriteTo write SQL to Writer
  30. func (notNull NotNull) WriteTo(w Writer) error {
  31. _, err := fmt.Fprintf(w, "%s IS NOT NULL", notNull[0])
  32. return err
  33. }
  34. // And implements And with other conditions
  35. func (notNull NotNull) And(conds ...Cond) Cond {
  36. return And(notNull, And(conds...))
  37. }
  38. // Or implements Or with other conditions
  39. func (notNull NotNull) Or(conds ...Cond) Cond {
  40. return Or(notNull, Or(conds...))
  41. }
  42. // IsValid tests if this condition is valid
  43. func (notNull NotNull) IsValid() bool {
  44. return len(notNull[0]) > 0
  45. }
上海开阖软件有限公司 沪ICP备12045867号-1