diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-09-29 20:52:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-29 20:52:39 +0800 |
commit | aa9a99cf5f7de47328e5a6ffcba6114294934031 (patch) | |
tree | cd5bc73f12a0a8bf7709dccdb18a4b7764563745 /vendor/xorm.io | |
parent | c6fb7fe27c16c4e43d4d8dbe4d2ff4b3c4c52a29 (diff) | |
download | gitea-aa9a99cf5f7de47328e5a6ffcba6114294934031.tar.gz gitea-aa9a99cf5f7de47328e5a6ffcba6114294934031.zip |
Upgrade xorm to latest to fix insert issue bug (#8309)
* upgrade xorm to latest to fix insert issue bug
* add newissue unit tests
* update xorm version
* fix tests
Diffstat (limited to 'vendor/xorm.io')
-rw-r--r-- | vendor/xorm.io/core/.drone.yml | 173 | ||||
-rw-r--r-- | vendor/xorm.io/core/filter.go | 27 | ||||
-rw-r--r-- | vendor/xorm.io/core/go.mod | 7 | ||||
-rw-r--r-- | vendor/xorm.io/core/go.sum | 27 | ||||
-rw-r--r-- | vendor/xorm.io/core/type.go | 4 |
5 files changed, 176 insertions, 62 deletions
diff --git a/vendor/xorm.io/core/.drone.yml b/vendor/xorm.io/core/.drone.yml index 1ef2b8134c..4cb2fb4ae6 100644 --- a/vendor/xorm.io/core/.drone.yml +++ b/vendor/xorm.io/core/.drone.yml @@ -1,42 +1,153 @@ +--- +kind: pipeline +name: go1.10 + +platform: + os: linux + arch: amd64 + +clone: + disable: true + workspace: base: /go path: src/xorm.io/core +steps: +- name: git + pull: default + image: plugins/git:next + settings: + depth: 50 + tags: true + +- name: test + pull: default + image: golang:1.10 + commands: + - go get github.com/stretchr/testify/assert + - go get github.com/go-xorm/sqlfiddle + - go get github.com/go-sql-driver/mysql + - go get github.com/mattn/go-sqlite3 + - go vet + - "go test -v -race -coverprofile=coverage.txt -covermode=atomic -dbConn=\"root:@tcp(mysql:3306)/core_test?charset=utf8mb4\"" + when: + event: + - push + - tag + - pull_request + +services: +- name: mysql + pull: default + image: mysql:5.7 + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: core_test + when: + event: + - push + - tag + - pull_request + +--- +kind: pipeline +name: go1.11 + +platform: + os: linux + arch: amd64 + clone: - git: - image: plugins/git:next + disable: true + +workspace: + base: /go + path: src/xorm.io/core + +steps: +- name: git + pull: default + image: plugins/git:next + settings: depth: 50 tags: true -matrix: - GO_VERSION: - - 1.9 - - 1.10 - - 1.11 - - 1.12 - -pipeline: - test: - image: golang:${GO_VERSION} - environment: - GOPROXY: https://goproxy.cn - commands: - - go get -u golang.org/x/lint/golint - - go get -u github.com/stretchr/testify/assert - - go get -u github.com/go-xorm/sqlfiddle - - go get -u github.com/go-sql-driver/mysql - - go get -u github.com/mattn/go-sqlite3 - - go vet - - go test -v -race -coverprofile=coverage.txt -covermode=atomic -dbConn="root:@tcp(mysql:3306)/core_test?charset=utf8mb4" - when: - event: [ push, tag, pull_request ] +- name: test + pull: default + image: golang:1.11 + commands: + - go vet + - "go test -v -race -coverprofile=coverage.txt -covermode=atomic -dbConn=\"root:@tcp(mysql:3306)/core_test?charset=utf8mb4\"" + environment: + GO111MODULE: "on" + GOPROXY: https://goproxy.cn + when: + event: + - push + - tag + - pull_request + +services: +- name: mysql + pull: default + image: mysql:5.7 + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: core_test + when: + event: + - push + - tag + - pull_request + +--- +kind: pipeline +name: go1.12 + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +workspace: + base: /go + path: src/xorm.io/core + +steps: +- name: git + pull: default + image: plugins/git:next + settings: + depth: 50 + tags: true +- name: test + pull: default + image: golang:1.12 + commands: + - go vet + - "go test -v -race -coverprofile=coverage.txt -covermode=atomic -dbConn=\"root:@tcp(mysql:3306)/core_test?charset=utf8mb4\"" + environment: + GO111MODULE: "on" + GOPROXY: https://goproxy.cn + when: + event: + - push + - tag + - pull_request services: - mysql: - image: mysql:5.7 - environment: - - MYSQL_DATABASE=core_test - - MYSQL_ALLOW_EMPTY_PASSWORD=yes - when: - event: [ push, tag, pull_request ]
\ No newline at end of file +- name: mysql + pull: default + image: mysql:5.7 + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: core_test + when: + event: + - push + - tag + - pull_request
\ No newline at end of file diff --git a/vendor/xorm.io/core/filter.go b/vendor/xorm.io/core/filter.go index aeea1223c3..55be9562bb 100644 --- a/vendor/xorm.io/core/filter.go +++ b/vendor/xorm.io/core/filter.go @@ -70,15 +70,24 @@ type SeqFilter struct { Start int } -func (s *SeqFilter) Do(sql string, dialect Dialect, table *Table) string { - segs := strings.Split(sql, "?") - size := len(segs) - res := "" - for i, c := range segs { - if i < size-1 { - res += c + fmt.Sprintf("%s%v", s.Prefix, i+s.Start) +func convertQuestionMark(sql, prefix string, start int) string { + var buf strings.Builder + var beginSingleQuote bool + var index = start + for _, c := range sql { + if !beginSingleQuote && c == '?' { + buf.WriteString(fmt.Sprintf("%s%v", prefix, index)) + index++ + } else { + if c == '\'' { + beginSingleQuote = !beginSingleQuote + } + buf.WriteRune(c) } } - res += segs[size-1] - return res + return buf.String() +} + +func (s *SeqFilter) Do(sql string, dialect Dialect, table *Table) string { + return convertQuestionMark(sql, s.Prefix, s.Start) } diff --git a/vendor/xorm.io/core/go.mod b/vendor/xorm.io/core/go.mod index 2ee3596814..9dc9c1f2e6 100644 --- a/vendor/xorm.io/core/go.mod +++ b/vendor/xorm.io/core/go.mod @@ -2,12 +2,7 @@ module xorm.io/core require ( github.com/go-sql-driver/mysql v1.4.1 - github.com/golang/protobuf v1.3.1 // indirect github.com/mattn/go-sqlite3 v1.10.0 - golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 // indirect - golang.org/x/net v0.0.0-20190603091049-60506f45cf65 // indirect - golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed // indirect - golang.org/x/text v0.3.2 // indirect - golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468 // indirect + github.com/stretchr/testify v1.4.0 google.golang.org/appengine v1.6.0 // indirect ) diff --git a/vendor/xorm.io/core/go.sum b/vendor/xorm.io/core/go.sum index 4248a62501..172009ed4a 100644 --- a/vendor/xorm.io/core/go.sum +++ b/vendor/xorm.io/core/go.sum @@ -1,23 +1,20 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.0 h1:Tfd7cKwKbFRsI8RMAD3oqqw7JPFRrvFlOsfbgVkjOOw= google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/xorm.io/core/type.go b/vendor/xorm.io/core/type.go index 14d6e12e2f..75b6c36387 100644 --- a/vendor/xorm.io/core/type.go +++ b/vendor/xorm.io/core/type.go @@ -93,6 +93,7 @@ var ( Time = "TIME" TimeStamp = "TIMESTAMP" TimeStampz = "TIMESTAMPZ" + Year = "YEAR" Decimal = "DECIMAL" Numeric = "NUMERIC" @@ -153,6 +154,7 @@ var ( TimeStamp: TIME_TYPE, TimeStampz: TIME_TYPE, SmallDateTime: TIME_TYPE, + Year: TIME_TYPE, Decimal: NUMERIC_TYPE, Numeric: NUMERIC_TYPE, @@ -313,7 +315,7 @@ func SQLType2Type(st SQLType) reflect.Type { return reflect.TypeOf([]byte{}) case Bool: return reflect.TypeOf(true) - case DateTime, Date, Time, TimeStamp, TimeStampz, SmallDateTime: + case DateTime, Date, Time, TimeStamp, TimeStampz, SmallDateTime, Year: return reflect.TypeOf(c_TIME_DEFAULT) case Decimal, Numeric, Money, SmallMoney: return reflect.TypeOf("") |