summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-09-03 09:58:04 +0800
committerGitHub <noreply@github.com>2020-09-03 02:58:04 +0100
commit514201af5d2e81182c86306f414ced27c8602eb6 (patch)
tree346e37b7b1ac5531dcd7bb50a5a58b4f1d375a01 /vendor
parent702e98c5ec7b11f3c988d61dccbec71e1e69a8bd (diff)
downloadgitea-514201af5d2e81182c86306f414ced27c8602eb6.tar.gz
gitea-514201af5d2e81182c86306f414ced27c8602eb6.zip
Upgrade xorm to v1.0.4 (#12694)
Diffstat (limited to 'vendor')
-rw-r--r--vendor/modules.txt2
-rw-r--r--vendor/xorm.io/xorm/.drone.yml32
-rw-r--r--vendor/xorm.io/xorm/README.md4
-rw-r--r--vendor/xorm.io/xorm/dialects/mysql.go21
-rw-r--r--vendor/xorm.io/xorm/internal/utils/strings.go1
-rw-r--r--vendor/xorm.io/xorm/session.go2
-rw-r--r--vendor/xorm.io/xorm/session_tx.go45
7 files changed, 53 insertions, 54 deletions
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 318768e77e..4a56342463 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -949,7 +949,7 @@ strk.kbt.io/projects/go/libravatar
# xorm.io/builder v0.3.7
## explicit
xorm.io/builder
-# xorm.io/xorm v1.0.4-0.20200718080127-318102c9ff87
+# xorm.io/xorm v1.0.4
## explicit
xorm.io/xorm
xorm.io/xorm/caches
diff --git a/vendor/xorm.io/xorm/.drone.yml b/vendor/xorm.io/xorm/.drone.yml
index 8cf43aa251..300c78410f 100644
--- a/vendor/xorm.io/xorm/.drone.yml
+++ b/vendor/xorm.io/xorm/.drone.yml
@@ -10,6 +10,7 @@ steps:
commands:
- make vet
- make test
+ - make fmt-check
when:
event:
- push
@@ -109,6 +110,25 @@ steps:
- push
- pull_request
+- name: test-mariadb
+ image: golang:1.12
+ environment:
+ GO111MODULE: "on"
+ GOPROXY: "https://goproxy.cn"
+ TEST_MYSQL_HOST: mariadb
+ TEST_MYSQL_CHARSET: utf8mb4
+ TEST_MYSQL_DBNAME: xorm_test
+ TEST_MYSQL_USERNAME: root
+ TEST_MYSQL_PASSWORD:
+ commands:
+ - make test-mysql
+ - TEST_CACHE_ENABLE=true make test-mysql
+ - TEST_QUOTE_POLICY=reserved make test-mysql
+ when:
+ event:
+ - push
+ - pull_request
+
- name: test-postgres
pull: default
image: golang:1.12
@@ -258,6 +278,18 @@ services:
- tag
- pull_request
+- name: mariadb
+ pull: default
+ image: mariadb:10.4
+ environment:
+ MYSQL_ALLOW_EMPTY_PASSWORD: yes
+ MYSQL_DATABASE: xorm_test
+ when:
+ event:
+ - push
+ - tag
+ - pull_request
+
- name: pgsql
pull: default
image: postgres:9.5
diff --git a/vendor/xorm.io/xorm/README.md b/vendor/xorm.io/xorm/README.md
index ed866224f9..6738083943 100644
--- a/vendor/xorm.io/xorm/README.md
+++ b/vendor/xorm.io/xorm/README.md
@@ -313,7 +313,7 @@ err := engine.Where(builder.NotIn("a", 1, 2).And(builder.In("b", "c", "d", "e"))
// SELECT id, name ... FROM user WHERE a NOT IN (?, ?) AND b IN (?, ?, ?)
```
-* Multiple operations in one go routine, no transation here but resue session memory
+* Multiple operations in one go routine, no transaction here but resue session memory
```Go
session := engine.NewSession()
@@ -336,7 +336,7 @@ if _, err := session.Exec("delete from userinfo where username = ?", user2.Usern
return nil
```
-* Transation should be on one go routine. There is transaction and resue session memory
+* Transaction should be on one go routine. There is transaction and resue session memory
```Go
session := engine.NewSession()
diff --git a/vendor/xorm.io/xorm/dialects/mysql.go b/vendor/xorm.io/xorm/dialects/mysql.go
index f9a2e9434d..32e18a17cc 100644
--- a/vendor/xorm.io/xorm/dialects/mysql.go
+++ b/vendor/xorm.io/xorm/dialects/mysql.go
@@ -307,9 +307,17 @@ func (db *mysql) AddColumnSQL(tableName string, col *schemas.Column) string {
func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error) {
args := []interface{}{db.uri.DBName, tableName}
+ alreadyQuoted := "(INSTR(VERSION(), 'maria') > 0 && " +
+ "(SUBSTRING_INDEX(VERSION(), '.', 1) > 10 || " +
+ "(SUBSTRING_INDEX(VERSION(), '.', 1) = 10 && " +
+ "(SUBSTRING_INDEX(SUBSTRING(VERSION(), 4), '.', 1) > 2 || " +
+ "(SUBSTRING_INDEX(SUBSTRING(VERSION(), 4), '.', 1) = 2 && " +
+ "SUBSTRING_INDEX(SUBSTRING(VERSION(), 6), '-', 1) >= 7)))))"
s := "SELECT `COLUMN_NAME`, `IS_NULLABLE`, `COLUMN_DEFAULT`, `COLUMN_TYPE`," +
- " `COLUMN_KEY`, `EXTRA`,`COLUMN_COMMENT` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?" +
- " ORDER BY `INFORMATION_SCHEMA`.`COLUMNS`.ORDINAL_POSITION"
+ " `COLUMN_KEY`, `EXTRA`, `COLUMN_COMMENT`, " +
+ alreadyQuoted + " AS NEEDS_QUOTE " +
+ "FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?" +
+ " ORDER BY `COLUMNS`.ORDINAL_POSITION"
rows, err := queryer.QueryContext(ctx, s, args...)
if err != nil {
@@ -324,8 +332,9 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
col.Indexes = make(map[string]int)
var columnName, isNullable, colType, colKey, extra, comment string
+ var alreadyQuoted bool
var colDefault *string
- err = rows.Scan(&columnName, &isNullable, &colDefault, &colType, &colKey, &extra, &comment)
+ err = rows.Scan(&columnName, &isNullable, &colDefault, &colType, &colKey, &extra, &comment, &alreadyQuoted)
if err != nil {
return nil, nil, err
}
@@ -335,7 +344,7 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
col.Nullable = true
}
- if colDefault != nil {
+ if colDefault != nil && (!alreadyQuoted || *colDefault != "NULL") {
col.Default = *colDefault
col.DefaultIsEmpty = false
} else {
@@ -404,9 +413,9 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
}
if !col.DefaultIsEmpty {
- if col.SQLType.IsText() {
+ if !alreadyQuoted && col.SQLType.IsText() {
col.Default = "'" + col.Default + "'"
- } else if col.SQLType.IsTime() && col.Default != "CURRENT_TIMESTAMP" {
+ } else if col.SQLType.IsTime() && !alreadyQuoted && col.Default != "CURRENT_TIMESTAMP" {
col.Default = "'" + col.Default + "'"
}
}
diff --git a/vendor/xorm.io/xorm/internal/utils/strings.go b/vendor/xorm.io/xorm/internal/utils/strings.go
index b5dc37b774..724667057c 100644
--- a/vendor/xorm.io/xorm/internal/utils/strings.go
+++ b/vendor/xorm.io/xorm/internal/utils/strings.go
@@ -27,4 +27,3 @@ func SplitNNoCase(s, sep string, n int) []string {
}
return strings.SplitN(s, s[idx:idx+len(sep)], n)
}
-
diff --git a/vendor/xorm.io/xorm/session.go b/vendor/xorm.io/xorm/session.go
index 48b3779eff..b6ab3eb5bf 100644
--- a/vendor/xorm.io/xorm/session.go
+++ b/vendor/xorm.io/xorm/session.go
@@ -102,7 +102,7 @@ func newSessionID() string {
func newSession(engine *Engine) *Session {
var ctx context.Context
if engine.logSessionID {
- ctx = context.WithValue(engine.defaultContext, log.SessionIDKey, newSessionID())
+ ctx = context.WithValue(engine.defaultContext, log.SessionIDKey, newSessionID())
} else {
ctx = engine.defaultContext
}
diff --git a/vendor/xorm.io/xorm/session_tx.go b/vendor/xorm.io/xorm/session_tx.go
index cd23cf89c1..57791703b5 100644
--- a/vendor/xorm.io/xorm/session_tx.go
+++ b/vendor/xorm.io/xorm/session_tx.go
@@ -4,12 +4,6 @@
package xorm
-import (
- "time"
-
- "xorm.io/xorm/log"
-)
-
// Begin a transaction
func (session *Session) Begin() error {
if session.isAutoCommit {
@@ -33,24 +27,7 @@ func (session *Session) Rollback() error {
session.isCommitedOrRollbacked = true
session.isAutoCommit = true
- start := time.Now()
- needSQL := session.DB().NeedLogSQL(session.ctx)
- if needSQL {
- session.engine.logger.BeforeSQL(log.LogContext{
- Ctx: session.ctx,
- SQL: "ROLL BACK",
- })
- }
- err := session.tx.Rollback()
- if needSQL {
- session.engine.logger.AfterSQL(log.LogContext{
- Ctx: session.ctx,
- SQL: "ROLL BACK",
- ExecuteTime: time.Now().Sub(start),
- Err: err,
- })
- }
- return err
+ return session.tx.Rollback()
}
return nil
}
@@ -62,25 +39,7 @@ func (session *Session) Commit() error {
session.isCommitedOrRollbacked = true
session.isAutoCommit = true
- start := time.Now()
- needSQL := session.DB().NeedLogSQL(session.ctx)
- if needSQL {
- session.engine.logger.BeforeSQL(log.LogContext{
- Ctx: session.ctx,
- SQL: "COMMIT",
- })
- }
- err := session.tx.Commit()
- if needSQL {
- session.engine.logger.AfterSQL(log.LogContext{
- Ctx: session.ctx,
- SQL: "COMMIT",
- ExecuteTime: time.Now().Sub(start),
- Err: err,
- })
- }
-
- if err != nil {
+ if err := session.tx.Commit(); err != nil {
return err
}