statement_columnmap.go 594 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2019 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 xorm
  5. import "strings"
  6. type columnMap []string
  7. func (m columnMap) contain(colName string) bool {
  8. if len(m) == 0 {
  9. return false
  10. }
  11. n := len(colName)
  12. for _, mk := range m {
  13. if len(mk) != n {
  14. continue
  15. }
  16. if strings.EqualFold(mk, colName) {
  17. return true
  18. }
  19. }
  20. return false
  21. }
  22. func (m *columnMap) add(colName string) bool {
  23. if m.contain(colName) {
  24. return false
  25. }
  26. *m = append(*m, colName)
  27. return true
  28. }