mirror of
https://github.com/go-gitea/gitea.git
synced 2024-08-19 19:13:25 +02:00
* Upgrade xorm to v1.0.0 * small nit * Fix tests * Update xorm * Update xorm * fix go.sum * fix test * Fix bug when dump * Fix bug * update xorm to latest * Fix migration test * update xorm to latest * Fix import order * Use xorm tag
67 lines
1.0 KiB
Go
Vendored
67 lines
1.0 KiB
Go
Vendored
// Copyright 2019 The Xorm Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package statements
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"xorm.io/xorm/schemas"
|
|
)
|
|
|
|
type columnMap []string
|
|
|
|
func (m columnMap) Contain(colName string) bool {
|
|
if len(m) == 0 {
|
|
return false
|
|
}
|
|
|
|
n := len(colName)
|
|
for _, mk := range m {
|
|
if len(mk) != n {
|
|
continue
|
|
}
|
|
if strings.EqualFold(mk, colName) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func (m columnMap) Len() int {
|
|
return len(m)
|
|
}
|
|
|
|
func (m columnMap) IsEmpty() bool {
|
|
return len(m) == 0
|
|
}
|
|
|
|
func (m *columnMap) Add(colName string) bool {
|
|
if m.Contain(colName) {
|
|
return false
|
|
}
|
|
*m = append(*m, colName)
|
|
return true
|
|
}
|
|
|
|
func getFlagForColumn(m map[string]bool, col *schemas.Column) (val bool, has bool) {
|
|
if len(m) == 0 {
|
|
return false, false
|
|
}
|
|
|
|
n := len(col.Name)
|
|
|
|
for mk := range m {
|
|
if len(mk) != n {
|
|
continue
|
|
}
|
|
if strings.EqualFold(mk, col.Name) {
|
|
return m[mk], true
|
|
}
|
|
}
|
|
|
|
return false, false
|
|
}
|