aboutsummaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>2019-09-25 14:02:54 -0500
committerLauris BH <lauris.buksis@zzdats.lv>2019-09-25 22:02:54 +0300
commitf8882f4fa909905311de86e80175184954464dc1 (patch)
tree16d1913271408a91b8e751171b90a5ab1f66c5a4 /vendor
parenta8c024043ca7a762c29e3ed97b791df541b219d9 (diff)
downloadgitea-f8882f4fa909905311de86e80175184954464dc1.tar.gz
gitea-f8882f4fa909905311de86e80175184954464dc1.zip
Update xorm (#8286)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/go-xorm/xorm/dialect_mssql.go3
-rw-r--r--vendor/github.com/go-xorm/xorm/session_insert.go8
-rw-r--r--vendor/github.com/go-xorm/xorm/statement_args.go53
-rw-r--r--vendor/modules.txt2
4 files changed, 58 insertions, 8 deletions
diff --git a/vendor/github.com/go-xorm/xorm/dialect_mssql.go b/vendor/github.com/go-xorm/xorm/dialect_mssql.go
index 61061cb252..ce4dd00c19 100644
--- a/vendor/github.com/go-xorm/xorm/dialect_mssql.go
+++ b/vendor/github.com/go-xorm/xorm/dialect_mssql.go
@@ -254,6 +254,9 @@ func (db *mssql) SqlType(c *core.Column) string {
case core.TinyInt:
res = core.TinyInt
c.Length = 0
+ case core.BigInt:
+ res = core.BigInt
+ c.Length = 0
default:
res = t
}
diff --git a/vendor/github.com/go-xorm/xorm/session_insert.go b/vendor/github.com/go-xorm/xorm/session_insert.go
index de6452909c..1e19ce7a4e 100644
--- a/vendor/github.com/go-xorm/xorm/session_insert.go
+++ b/vendor/github.com/go-xorm/xorm/session_insert.go
@@ -25,6 +25,12 @@ func (session *Session) Insert(beans ...interface{}) (int64, error) {
defer session.Close()
}
+ session.autoResetStatement = false
+ defer func() {
+ session.autoResetStatement = true
+ session.resetStatement()
+ }()
+
for _, bean := range beans {
switch bean.(type) {
case map[string]interface{}:
@@ -35,7 +41,6 @@ func (session *Session) Insert(beans ...interface{}) (int64, error) {
affected += cnt
case []map[string]interface{}:
s := bean.([]map[string]interface{})
- session.autoResetStatement = false
for i := 0; i < len(s); i++ {
cnt, err := session.insertMapInterface(s[i])
if err != nil {
@@ -51,7 +56,6 @@ func (session *Session) Insert(beans ...interface{}) (int64, error) {
affected += cnt
case []map[string]string:
s := bean.([]map[string]string)
- session.autoResetStatement = false
for i := 0; i < len(s); i++ {
cnt, err := session.insertMapString(s[i])
if err != nil {
diff --git a/vendor/github.com/go-xorm/xorm/statement_args.go b/vendor/github.com/go-xorm/xorm/statement_args.go
index 4ce336f48e..23496443f9 100644
--- a/vendor/github.com/go-xorm/xorm/statement_args.go
+++ b/vendor/github.com/go-xorm/xorm/statement_args.go
@@ -6,17 +6,60 @@ package xorm
import (
"fmt"
+ "reflect"
+ "strings"
+ "time"
"xorm.io/builder"
"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 {
switch argv := arg.(type) {
- case string:
- if _, err := w.WriteString("'" + argv + "'"); err != nil {
- return err
- }
case bool:
if statement.Engine.dialect.DBType() == core.MSSQL {
if argv {
@@ -50,7 +93,7 @@ func (statement *Statement) writeArg(w *builder.BytesWriter, arg interface{}) er
return err
}
default:
- if _, err := w.WriteString(fmt.Sprintf("%v", argv)); err != nil {
+ if _, err := w.WriteString(convertArg(arg)); err != nil {
return err
}
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 56df013a5d..d64735c5fe 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -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/generator
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/gobwas/glob v0.2.3
github.com/gobwas/glob