mirror of https://github.com/go-gitea/gitea.git
parent
a8c024043c
commit
f8882f4fa9
2
go.mod
2
go.mod
|
@ -48,7 +48,7 @@ require (
|
||||||
github.com/go-redis/redis v6.15.2+incompatible
|
github.com/go-redis/redis v6.15.2+incompatible
|
||||||
github.com/go-sql-driver/mysql v1.4.1
|
github.com/go-sql-driver/mysql v1.4.1
|
||||||
github.com/go-swagger/go-swagger v0.20.1
|
github.com/go-swagger/go-swagger v0.20.1
|
||||||
github.com/go-xorm/xorm v0.7.8-0.20190924080535-59ed80ce1a67
|
github.com/go-xorm/xorm v0.7.8-0.20190925172902-71947cf034b6
|
||||||
github.com/gobwas/glob v0.2.3
|
github.com/gobwas/glob v0.2.3
|
||||||
github.com/gogits/chardet v0.0.0-20150115103509-2404f7772561
|
github.com/gogits/chardet v0.0.0-20150115103509-2404f7772561
|
||||||
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
|
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -250,8 +250,8 @@ github.com/go-swagger/scan-repo-boundary v0.0.0-20180623220736-973b3573c013/go.m
|
||||||
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
|
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
|
||||||
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
|
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
|
||||||
github.com/go-xorm/xorm v0.7.6/go.mod h1:nqz2TAsuOHWH2yk4FYWtacCGgdbrcdZ5mF1XadqEHls=
|
github.com/go-xorm/xorm v0.7.6/go.mod h1:nqz2TAsuOHWH2yk4FYWtacCGgdbrcdZ5mF1XadqEHls=
|
||||||
github.com/go-xorm/xorm v0.7.8-0.20190924080535-59ed80ce1a67 h1:mB5RWONyATkQ48+iQZ1lCZNPG3tABilyaEOxDm1QWyU=
|
github.com/go-xorm/xorm v0.7.8-0.20190925172902-71947cf034b6 h1:kwKsKxuD8cUIOHWaMk5nuBU9ZUTnGpN2c/e4Mt6RTAo=
|
||||||
github.com/go-xorm/xorm v0.7.8-0.20190924080535-59ed80ce1a67/go.mod h1:RSsmsVARCy4sayuKWFPaVNQMPYGLNRIK71YIVvgImL0=
|
github.com/go-xorm/xorm v0.7.8-0.20190925172902-71947cf034b6/go.mod h1:RSsmsVARCy4sayuKWFPaVNQMPYGLNRIK71YIVvgImL0=
|
||||||
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
|
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
|
||||||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||||
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
|
|
|
@ -254,6 +254,9 @@ func (db *mssql) SqlType(c *core.Column) string {
|
||||||
case core.TinyInt:
|
case core.TinyInt:
|
||||||
res = core.TinyInt
|
res = core.TinyInt
|
||||||
c.Length = 0
|
c.Length = 0
|
||||||
|
case core.BigInt:
|
||||||
|
res = core.BigInt
|
||||||
|
c.Length = 0
|
||||||
default:
|
default:
|
||||||
res = t
|
res = t
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,12 @@ func (session *Session) Insert(beans ...interface{}) (int64, error) {
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session.autoResetStatement = false
|
||||||
|
defer func() {
|
||||||
|
session.autoResetStatement = true
|
||||||
|
session.resetStatement()
|
||||||
|
}()
|
||||||
|
|
||||||
for _, bean := range beans {
|
for _, bean := range beans {
|
||||||
switch bean.(type) {
|
switch bean.(type) {
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
|
@ -35,7 +41,6 @@ func (session *Session) Insert(beans ...interface{}) (int64, error) {
|
||||||
affected += cnt
|
affected += cnt
|
||||||
case []map[string]interface{}:
|
case []map[string]interface{}:
|
||||||
s := bean.([]map[string]interface{})
|
s := bean.([]map[string]interface{})
|
||||||
session.autoResetStatement = false
|
|
||||||
for i := 0; i < len(s); i++ {
|
for i := 0; i < len(s); i++ {
|
||||||
cnt, err := session.insertMapInterface(s[i])
|
cnt, err := session.insertMapInterface(s[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -51,7 +56,6 @@ func (session *Session) Insert(beans ...interface{}) (int64, error) {
|
||||||
affected += cnt
|
affected += cnt
|
||||||
case []map[string]string:
|
case []map[string]string:
|
||||||
s := bean.([]map[string]string)
|
s := bean.([]map[string]string)
|
||||||
session.autoResetStatement = false
|
|
||||||
for i := 0; i < len(s); i++ {
|
for i := 0; i < len(s); i++ {
|
||||||
cnt, err := session.insertMapString(s[i])
|
cnt, err := session.insertMapString(s[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -6,17 +6,60 @@ package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/core"
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func quoteNeeded(a interface{}) bool {
|
||||||
|
switch a.(type) {
|
||||||
|
case int, int8, int16, int32, int64:
|
||||||
|
return false
|
||||||
|
case uint, uint8, uint16, uint32, uint64:
|
||||||
|
return false
|
||||||
|
case float32, float64:
|
||||||
|
return false
|
||||||
|
case bool:
|
||||||
|
return false
|
||||||
|
case string:
|
||||||
|
return true
|
||||||
|
case time.Time, *time.Time:
|
||||||
|
return true
|
||||||
|
case builder.Builder, *builder.Builder:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
t := reflect.TypeOf(a)
|
||||||
|
switch t.Kind() {
|
||||||
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||||
|
return false
|
||||||
|
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||||
|
return false
|
||||||
|
case reflect.Float32, reflect.Float64:
|
||||||
|
return false
|
||||||
|
case reflect.Bool:
|
||||||
|
return false
|
||||||
|
case reflect.String:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertArg(arg interface{}) string {
|
||||||
|
if quoteNeeded(arg) {
|
||||||
|
argv := fmt.Sprintf("%v", arg)
|
||||||
|
return "'" + strings.Replace(argv, "'", "''", -1) + "'"
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%v", arg)
|
||||||
|
}
|
||||||
|
|
||||||
func (statement *Statement) writeArg(w *builder.BytesWriter, arg interface{}) error {
|
func (statement *Statement) writeArg(w *builder.BytesWriter, arg interface{}) error {
|
||||||
switch argv := arg.(type) {
|
switch argv := arg.(type) {
|
||||||
case string:
|
|
||||||
if _, err := w.WriteString("'" + argv + "'"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
case bool:
|
case bool:
|
||||||
if statement.Engine.dialect.DBType() == core.MSSQL {
|
if statement.Engine.dialect.DBType() == core.MSSQL {
|
||||||
if argv {
|
if argv {
|
||||||
|
@ -50,7 +93,7 @@ func (statement *Statement) writeArg(w *builder.BytesWriter, arg interface{}) er
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if _, err := w.WriteString(fmt.Sprintf("%v", argv)); err != nil {
|
if _, err := w.WriteString(convertArg(arg)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ github.com/go-swagger/go-swagger/cmd/swagger/commands/initcmd
|
||||||
github.com/go-swagger/go-swagger/codescan
|
github.com/go-swagger/go-swagger/codescan
|
||||||
github.com/go-swagger/go-swagger/generator
|
github.com/go-swagger/go-swagger/generator
|
||||||
github.com/go-swagger/go-swagger/scan
|
github.com/go-swagger/go-swagger/scan
|
||||||
# github.com/go-xorm/xorm v0.7.8-0.20190924080535-59ed80ce1a67
|
# github.com/go-xorm/xorm v0.7.8-0.20190925172902-71947cf034b6
|
||||||
github.com/go-xorm/xorm
|
github.com/go-xorm/xorm
|
||||||
# github.com/gobwas/glob v0.2.3
|
# github.com/gobwas/glob v0.2.3
|
||||||
github.com/gobwas/glob
|
github.com/gobwas/glob
|
||||||
|
|
Loading…
Reference in New Issue