[MM-25673] Upgrades and migrations to start using master gorp (#14823)

Database changes needed to reflect gorp master changes
Этот коммит содержится в:
Mario de Frutos Dieguez
2020-08-18 10:43:56 +02:00
коммит произвёл GitHub
родитель 0302e0f477
Коммит f619de2c83
56 изменённых файлов: 461 добавлений и 4889 удалений

33
vendor/github.com/mattermost/gorp/.travis.yml сгенерированный поставляемый
Просмотреть файл

@@ -1,33 +0,0 @@
language: go
go:
- 1.6
- 1.7
- tip
matrix:
allow_failures:
- go: tip
services:
- mysql
- postgres
- sqlite3
env:
global:
- secure: RriLxF6+2yMl67hdVv8ImXlu0h62mhcpqjaOgYNU+IEbUQ7hx96CKY6gkpYubW3BgApvF5RH6j3+HKvh2kGp0XhDOYOQCODfBSaSipZ5Aa5RKjsEYLtuVIobvJ80awR9hUeql69+WXs0/s72WThG0qTbOUY4pqHWfteeY235hWM=
before_script:
- mysql -e "CREATE DATABASE gorptest;"
- mysql -u root -e "GRANT ALL ON gorptest.* TO gorptest@localhost IDENTIFIED BY 'gorptest'"
- psql -c "CREATE DATABASE gorptest;" -U postgres
- psql -c "CREATE USER "gorptest" WITH SUPERUSER PASSWORD 'gorptest';" -U postgres
- go get github.com/lib/pq
- go get github.com/mattn/go-sqlite3
- go get github.com/ziutek/mymysql/godrv
- go get github.com/go-sql-driver/mysql
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
- go get github.com/onsi/ginkgo/ginkgo
script: ./test_all.sh

24
vendor/github.com/mattermost/gorp/Makefile сгенерированный поставляемый Обычный файл
Просмотреть файл

@@ -0,0 +1,24 @@
GOTESTFLAGS ?= -test.count=1
test-all: test-unit test-mymysql test-gomysql test-postgres test-sqlite
test-unit:
echo "Running unit tests"
ginkgo -r -race -randomizeAllSpecs -keepGoing -- -test.run TestGorp
test-mymysql:
echo "Testing against mymysql"
go test . $(GOTESTFLAGS) -dsn="tcp:localhost:3306*gorptest/gorptest/gorptest" -dialect="mysql"
test-gomysql:
echo "Testing against gomysql"
go test . $(GOTESTFLAGS) -dsn="gorptest:gorptest@tcp(localhost:3306)/gorptest" -dialect="gomysql"
test-postgres:
echo "Testing against postgres"
go test . $(GOTESTFLAGS) -dsn="host=localhost user=gorptest password=gorptest dbname=gorptest sslmode=disable" -dialect="postgres"
test-sqlite:
echo "Testing against sqlite"
go test . $(GOTESTFLAGS) -dsn="/tmp/gorptest.bin" -dialect="sqlite"
rm -f /tmp/gorptest.bin

42
vendor/github.com/mattermost/gorp/README.md сгенерированный поставляемый
Просмотреть файл

@@ -536,9 +536,9 @@ func (i *Invoice) PreUpdate(s gorp.SqlExecutor) error {
//
func (p *Person) PreDelete(s gorp.SqlExecutor) error {
query := "delete from invoice_test where PersonId=?"
_, err := s.Exec(query, p.Id)
if err != nil {
return err
}
@@ -655,7 +655,7 @@ MariaDB [test]> show create table Account;
`AcctId` varchar(255) DEFAULT NULL,
PRIMARY KEY (`Id`),
UNIQUE KEY `AcctIdIndex` (`AcctId`) USING BTREE <<<--- yes! index added.
) ENGINE=InnoDB DEFAULT CHARSET=utf8
) ENGINE=InnoDB DEFAULT CHARSET=utf8
+---------+--------------------------+
```
@@ -732,14 +732,18 @@ Raw SQL strings passed to `Exec`, `Select`, `SelectOne`, `SelectInt`,
etc will not be parsed. Consequently you may have portability issues
if you write a query like this:
```go // works on MySQL and Sqlite3, but not with Postgresql err :=
```go
go // works on MySQL and Sqlite3, but not with Postgresql err :=
dbmap.SelectOne(&val, "select * from foo where id = ?", 30) ```
```
In `Select` and `SelectOne` you can use named parameters to work
around this. The following is portable:
```go err := dbmap.SelectOne(&val, "select * from foo where id = :id",
map[string]interface{} { "id": 30}) ```
```go
go err := dbmap.SelectOne(&val, "select * from foo where id = :id",
map[string]interface{} { "id": 30})
```
Additionally, when using Postgres as your database, you should utilize
`$1` instead of `?` placeholders as utilizing `?` placeholders when
@@ -753,8 +757,7 @@ gorp will pass `time.Time` fields through to the `database/sql`
driver, but note that the behavior of this type varies across database
drivers.
MySQL users should be especially cautious. See:
https://github.com/ziutek/mymysql/pull/77
MySQL users should be especially cautious. See [this PR](https://github.com/ziutek/mymysql/pull/77)
To avoid any potential issues with timezone/DST, consider:
@@ -766,25 +769,26 @@ To avoid any potential issues with timezone/DST, consider:
## Running the tests
The included tests may be run against MySQL, Postgresql, or sqlite3.
You must set two environment variables so the test code knows which
driver to use, and how to connect to your database.
You must set two flags, dsn and dialect, in order to test the environment you want.
If not flag is passed the tests are going to use the default ones which are:
- DSN: `gorptest:gorptest@tcp(localhost:3306)/gorptest`
- Dialect: `gomysql`
```sh
```bash
# MySQL example:
export GORP_TEST_DSN=gomysql_test/gomysql_test/abc123
export GORP_TEST_DIALECT=mysql
# run the tests
go test
go test -dsn="gorptest:gorptest@tcp(localhost:3306)/gorptest" -dialect="gomysql"
# run the tests and benchmarks
go test -bench="Bench" -benchtime 10
```
Valid `GORP_TEST_DIALECT` values are: "mysql"(for mymysql),
"gomysql"(for go-sql-driver), "postgres", "sqlite" See the
`test_all.sh` script for examples of all 3 databases. This is the
script I run locally to test the library.
Valid `dialect` flag values are:
- [mysql](https://github.com/ziutek/mymysql)
- [gomysql](https://github.com/Go-SQL-Driver/MySQL)
- [postgres](https://github.com/lib/pq)
- [sqlite](https://github.com/mattn/go-sqlite3)
## Performance

5
vendor/github.com/mattermost/gorp/db.go сгенерированный поставляемый
Просмотреть файл

@@ -12,7 +12,6 @@
package gorp
import (
"bytes"
"context"
"database/sql"
"database/sql/driver"
@@ -100,7 +99,7 @@ func (m *DbMap) CreateIndex() error {
func (m *DbMap) createIndexImpl(dialect reflect.Type,
table *TableMap,
index *IndexMap) error {
s := bytes.Buffer{}
s := strings.Builder{}
s.WriteString("create")
if index.Unique {
s.WriteString(" unique")
@@ -133,7 +132,7 @@ func (t *TableMap) DropIndex(name string) error {
dialect := reflect.TypeOf(t.dbmap.Dialect)
for _, idx := range t.indexes {
if idx.IndexName == name {
s := bytes.Buffer{}
s := strings.Builder{}
s.WriteString(fmt.Sprintf("DROP INDEX %s", idx.IndexName))
if dname := dialect.Name(); dname == "MySQLDialect" {

24
vendor/github.com/mattermost/gorp/dialect_mysql.go сгенерированный поставляемый
Просмотреть файл

@@ -72,21 +72,21 @@ func (d MySQLDialect) ToSqlType(val reflect.Type, maxsize int, isAutoIncr bool)
return "datetime"
}
if maxsize < 1 {
maxsize = 255
}
/* == About varchar(N) ==
* N is number of characters.
* A varchar column can store up to 65535 bytes.
* Remember that 1 character is 3 bytes in utf-8 charset.
* Also remember that each row can store up to 65535 bytes,
* and you have some overheads, so it's not possible for a
* varchar column to have 65535/3 characters really.
* So it would be better to use 'text' type in stead of
* large varchar type.
* According to the documentation, 0 < N <= 65535.
* But one utf-8 character takes 3 bytes and each row can
* be only 65535 bytes. So there is no way to know exactly
* how many chars a varchar column can actually store.
* Text columns contribute only up to 12 bytes to the row
* size as their contents are stored off-page.
* Hence, we use a conservative maximum of 512 for varchar,
* after which we switch to the text type.
*/
if maxsize < 256 {
if maxsize == 0 {
// Closer match for unbounded text
return "longtext"
} else if maxsize < 256 {
return fmt.Sprintf("varchar(%d)", maxsize)
} else {
return "text"

13
vendor/github.com/mattermost/gorp/go.mod сгенерированный поставляемый Обычный файл
Просмотреть файл

@@ -0,0 +1,13 @@
module github.com/mattermost/gorp
go 1.13
require (
github.com/go-sql-driver/mysql v1.5.0
github.com/lib/pq v1.3.0
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/onsi/ginkgo v1.13.0
github.com/onsi/gomega v1.10.1
github.com/ziutek/mymysql v1.5.4
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect
)

79
vendor/github.com/mattermost/gorp/go.sum сгенерированный поставляемый Обычный файл
Просмотреть файл

@@ -0,0 +1,79 @@
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.13.0 h1:M76yO2HkZASFjXL0HSoZJ1AYEmQxNJmY41Jx1zNUq1Y=
github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
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/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
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/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

12
vendor/github.com/mattermost/gorp/gorp.go сгенерированный поставляемый
Просмотреть файл

@@ -257,15 +257,15 @@ func columnToFieldIndex(m *DbMap, t reflect.Type, name string, cols []string) ([
cArguments := strings.Split(field.Tag.Get("db"), ",")
fieldName = cArguments[0]
if tableMapped {
colMap := colMapOrNil(table, fieldName)
if colMap != nil {
fieldName = colMap.ColumnName
}
}
if fieldName == "" || fieldName == "-" {
fieldName = field.Name
}
if tableMapped {
colMap := colMapOrNil(table, fieldName)
if colMap != nil && colMap.ColumnName != "-" {
fieldName = colMap.ColumnName
}
}
return colName == strings.ToLower(fieldName)
})
if found {

44
vendor/github.com/mattermost/gorp/nulltypes.go сгенерированный поставляемый
Просмотреть файл

@@ -28,22 +28,34 @@ func (nt *NullTime) Scan(value interface{}) error {
case time.Time:
nt.Time, nt.Valid = t, true
case []byte:
nt.Valid = false
for _, dtfmt := range []string{
"2006-01-02 15:04:05.999999999",
"2006-01-02T15:04:05.999999999",
"2006-01-02 15:04:05",
"2006-01-02T15:04:05",
"2006-01-02 15:04",
"2006-01-02T15:04",
"2006-01-02",
"2006-01-02 15:04:05-07:00",
} {
var err error
if nt.Time, err = time.Parse(dtfmt, string(t)); err == nil {
nt.Valid = true
break
}
v := strToTime(string(t))
if v != nil {
nt.Valid = true
nt.Time = *v
}
case string:
v := strToTime(t)
if v != nil {
nt.Valid = true
nt.Time = *v
}
}
return nil
}
func strToTime(v string) *time.Time {
for _, dtfmt := range []string{
"2006-01-02 15:04:05.999999999",
"2006-01-02T15:04:05.999999999",
"2006-01-02 15:04:05",
"2006-01-02T15:04:05",
"2006-01-02 15:04",
"2006-01-02T15:04",
"2006-01-02",
"2006-01-02 15:04:05-07:00",
} {
if t, err := time.Parse(dtfmt, v); err == nil {
return &t
}
}
return nil

3
vendor/github.com/mattermost/gorp/table.go сгенерированный поставляемый
Просмотреть файл

@@ -12,7 +12,6 @@
package gorp
import (
"bytes"
"fmt"
"reflect"
"strings"
@@ -189,7 +188,7 @@ func (t *TableMap) SetVersionCol(field string) *ColumnMap {
// SqlForCreateTable gets a sequence of SQL commands that will create
// the specified table and any associated schema
func (t *TableMap) SqlForCreate(ifNotExists bool) string {
s := bytes.Buffer{}
s := strings.Builder{}
dialect := t.dbmap.Dialect
if strings.TrimSpace(t.SchemaName) != "" {

12
vendor/github.com/mattermost/gorp/table_bindings.go сгенерированный поставляемый
Просмотреть файл

@@ -12,9 +12,9 @@
package gorp
import (
"bytes"
"fmt"
"reflect"
"strings"
"sync"
)
@@ -113,8 +113,8 @@ func (t *TableMap) bindInsert(elem reflect.Value) (bindInstance, error) {
plan.once.Do(func() {
plan.autoIncrIdx = -1
s := bytes.Buffer{}
s2 := bytes.Buffer{}
s := strings.Builder{}
s2 := strings.Builder{}
s.WriteString(fmt.Sprintf("insert into %s (", t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName)))
x := 0
@@ -175,7 +175,7 @@ func (t *TableMap) bindUpdate(elem reflect.Value, colFilter ColumnFilter) (bindI
plan := &t.updatePlan
plan.once.Do(func() {
s := bytes.Buffer{}
s := strings.Builder{}
s.WriteString(fmt.Sprintf("update %s set ", t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName)))
x := 0
@@ -231,7 +231,7 @@ func (t *TableMap) bindUpdate(elem reflect.Value, colFilter ColumnFilter) (bindI
func (t *TableMap) bindDelete(elem reflect.Value) (bindInstance, error) {
plan := &t.deletePlan
plan.once.Do(func() {
s := bytes.Buffer{}
s := strings.Builder{}
s.WriteString(fmt.Sprintf("delete from %s", t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName)))
for y := range t.Columns {
@@ -275,7 +275,7 @@ func (t *TableMap) bindDelete(elem reflect.Value) (bindInstance, error) {
func (t *TableMap) bindGet() *bindPlan {
plan := &t.getPlan
plan.once.Do(func() {
s := bytes.Buffer{}
s := strings.Builder{}
s.WriteString("select ")
x := 0

41
vendor/github.com/mattermost/gorp/test_all.sh сгенерированный поставляемый
Просмотреть файл

@@ -1,41 +0,0 @@
#!/bin/bash -e
# on macs, you may need to:
# export GOBUILDFLAG=-ldflags -linkmode=external
coveralls_testflags="-v -covermode=count -coverprofile=coverage.out"
echo "Running unit tests"
ginkgo -r -race -randomizeAllSpecs -keepGoing -- -test.run TestGorp
echo "Testing against mysql"
export GORP_TEST_DSN=gorptest/gorptest/gorptest
export GORP_TEST_DIALECT=mysql
go test $coveralls_testflags $GOBUILDFLAG $@ .
echo "Testing against gomysql"
export GORP_TEST_DSN=gorptest:gorptest@/gorptest
export GORP_TEST_DIALECT=gomysql
go test $coveralls_testflags $GOBUILDFLAG $@ .
echo "Testing against postgres"
export GORP_TEST_DSN="user=gorptest password=gorptest dbname=gorptest sslmode=disable"
export GORP_TEST_DIALECT=postgres
go test $coveralls_testflags $GOBUILDFLAG $@ .
echo "Testing against sqlite"
export GORP_TEST_DSN=/tmp/gorptest.bin
export GORP_TEST_DIALECT=sqlite
go test $coveralls_testflags $GOBUILDFLAG $@ .
rm -f /tmp/gorptest.bin
case $(go version) in
*go1.4*)
if [ "$(type -p goveralls)" != "" ]; then
goveralls -covermode=count -coverprofile=coverage.out -service=travis-ci
elif [ -x $HOME/gopath/bin/goveralls ]; then
$HOME/gopath/bin/goveralls -covermode=count -coverprofile=coverage.out -service=travis-ci
fi
;;
*) ;;
esac