forked from forgejo/forgejo
Update xorm to latest version (#1651)
* Update xorm to latest version * Update xorm/builder
This commit is contained in:
parent
0144817971
commit
3792867955
18 changed files with 251 additions and 141 deletions
59
vendor/github.com/go-xorm/builder/cond_notin.go
generated
vendored
59
vendor/github.com/go-xorm/builder/cond_notin.go
generated
vendored
|
@ -6,6 +6,7 @@ package builder
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -18,16 +19,23 @@ func NotIn(col string, values ...interface{}) Cond {
|
|||
return condNotIn{col, values}
|
||||
}
|
||||
|
||||
func (condNotIn condNotIn) handleBlank(w Writer) error {
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN ()", condNotIn.col); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (condNotIn condNotIn) WriteTo(w Writer) error {
|
||||
if len(condNotIn.vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
|
||||
switch condNotIn.vals[0].(type) {
|
||||
case []int8:
|
||||
vals := condNotIn.vals[0].([]int8)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -39,7 +47,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []int16:
|
||||
vals := condNotIn.vals[0].([]int16)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -51,7 +59,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []int:
|
||||
vals := condNotIn.vals[0].([]int)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -63,7 +71,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []int32:
|
||||
vals := condNotIn.vals[0].([]int32)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -75,7 +83,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []int64:
|
||||
vals := condNotIn.vals[0].([]int64)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -87,7 +95,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []uint8:
|
||||
vals := condNotIn.vals[0].([]uint8)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -99,7 +107,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []uint16:
|
||||
vals := condNotIn.vals[0].([]uint16)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -111,7 +119,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []uint:
|
||||
vals := condNotIn.vals[0].([]uint)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -123,7 +131,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []uint32:
|
||||
vals := condNotIn.vals[0].([]uint32)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -135,7 +143,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []uint64:
|
||||
vals := condNotIn.vals[0].([]uint64)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -147,7 +155,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []string:
|
||||
vals := condNotIn.vals[0].([]string)
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -159,7 +167,7 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
case []interface{}:
|
||||
vals := condNotIn.vals[0].([]interface{})
|
||||
if len(vals) <= 0 {
|
||||
return ErrNoNotInConditions
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
questionMark := strings.Repeat("?,", len(vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
|
@ -189,11 +197,28 @@ func (condNotIn condNotIn) WriteTo(w Writer) error {
|
|||
return err
|
||||
}
|
||||
default:
|
||||
questionMark := strings.Repeat("?,", len(condNotIn.vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
return err
|
||||
v := reflect.ValueOf(condNotIn.vals[0])
|
||||
if v.Kind() == reflect.Slice {
|
||||
l := v.Len()
|
||||
if l == 0 {
|
||||
return condNotIn.handleBlank(w)
|
||||
}
|
||||
|
||||
questionMark := strings.Repeat("?,", l)
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < l; i++ {
|
||||
w.Append(v.Index(i).Interface())
|
||||
}
|
||||
} else {
|
||||
questionMark := strings.Repeat("?,", len(condNotIn.vals))
|
||||
if _, err := fmt.Fprintf(w, "%s NOT IN (%s)", condNotIn.col, questionMark[:len(questionMark)-1]); err != nil {
|
||||
return err
|
||||
}
|
||||
w.Append(condNotIn.vals...)
|
||||
}
|
||||
w.Append(condNotIn.vals...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue