diff options
author | 6543 <6543@obermui.de> | 2021-04-23 02:08:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-22 20:08:53 -0400 |
commit | 792b4dba2cc1b011e25f4a0c18fb648849cd885c (patch) | |
tree | fc5679ced43137a7b04ab1fb73dd2a4bd3ca9815 /vendor/github.com/go-testfixtures | |
parent | 834fc74873e8047552e9181e130bd53d8e890eb0 (diff) | |
download | gitea-792b4dba2cc1b011e25f4a0c18fb648849cd885c.tar.gz gitea-792b4dba2cc1b011e25f4a0c18fb648849cd885c.zip |
[Vendor] Update directly used dependencys (#15593)
* update github.com/blevesearch/bleve v2.0.2 -> v2.0.3
* github.com/denisenkom/go-mssqldb v0.9.0 -> v0.10.0
* github.com/editorconfig/editorconfig-core-go v2.4.1 -> v2.4.2
* github.com/go-chi/cors v1.1.1 -> v1.2.0
* github.com/go-git/go-billy v5.0.0 -> v5.1.0
* github.com/go-git/go-git v5.2.0 -> v5.3.0
* github.com/go-ldap/ldap v3.2.4 -> v3.3.0
* github.com/go-redis/redis v8.6.0 -> v8.8.2
* github.com/go-sql-driver/mysql v1.5.0 -> v1.6.0
* github.com/go-swagger/go-swagger v0.26.1 -> v0.27.0
* github.com/lib/pq v1.9.0 -> v1.10.1
* github.com/mattn/go-sqlite3 v1.14.6 -> v1.14.7
* github.com/go-testfixtures/testfixtures v3.5.0 -> v3.6.0
* github.com/issue9/identicon v1.0.1 -> v1.2.0
* github.com/klauspost/compress v1.11.8 -> v1.12.1
* github.com/mgechev/revive v1.0.3 -> v1.0.6
* github.com/microcosm-cc/bluemonday v1.0.7 -> v1.0.8
* github.com/niklasfasching/go-org v1.4.0 -> v1.5.0
* github.com/olivere/elastic v7.0.22 -> v7.0.24
* github.com/pelletier/go-toml v1.8.1 -> v1.9.0
* github.com/prometheus/client_golang v1.9.0 -> v1.10.0
* github.com/xanzy/go-gitlab v0.44.0 -> v0.48.0
* github.com/yuin/goldmark v1.3.3 -> v1.3.5
* github.com/6543/go-version v1.2.4 -> v1.3.1
* do github.com/lib/pq v1.10.0 -> v1.10.1 again ...
Diffstat (limited to 'vendor/github.com/go-testfixtures')
9 files changed, 99 insertions, 70 deletions
diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/.gitignore b/vendor/github.com/go-testfixtures/testfixtures/v3/.gitignore index 8772d9ba0c..a838ad49aa 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/.gitignore +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/.gitignore @@ -27,3 +27,4 @@ _testmain.go .env /testfixtures /dist +/tmp diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md b/vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md index 1827f18581..1cab63cedc 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## v3.6.0 - 2021-04-17 + +- Add support for dumping a database using the CLI (use the `--dump` flag) + ([#88](https://github.com/go-testfixtures/testfixtures/pull/88), [#63](https://github.com/go-testfixtures/testfixtures/issues/63)). +- Support SkipResetSequences and ResetSequencesTo for MySQL and MariaDB + ([#91](https://github.com/go-testfixtures/testfixtures/pull/91)). + ## v3.5.0 - 2021-01-11 - Fix insert of JSON values on PostgreSQL when using `binary_parameters=yes` in diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/README.md b/vendor/github.com/go-testfixtures/testfixtures/v3/README.md index 8b8748853d..1c6bc293c3 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/README.md +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/README.md @@ -406,11 +406,11 @@ dumper, err := testfixtures.NewDumper( testfixtures.DumpDatabase(db), testfixtures.DumpDialect("postgres"), // or your database of choice testfixtures.DumpDirectory("tmp/fixtures"), - textfixtures.DumpTables( // optional, will dump all table if not given + testfixtures.DumpTables( // optional, will dump all table if not given "posts", "comments", "tags", - ) + ), ) if err != nil { ... @@ -454,9 +454,15 @@ brew install go-testfixtures/tap/testfixtures Usage is like this: ```bash +# load testfixtures -d postgres -c "postgres://user:password@localhost/database" -D testdata/fixtures ``` +```bash +# dump +testfixtures --dump -d postgres -c "postgres://user:password@localhost/database" -D testdata/fixtures +``` + The connection string changes for each database driver. Use `testfixtures --help` for all flags. diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/go.mod b/vendor/github.com/go-testfixtures/testfixtures/v3/go.mod index 0ac4283601..71e1594754 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/go.mod +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/go.mod @@ -2,14 +2,13 @@ module github.com/go-testfixtures/testfixtures/v3 require ( github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73 - github.com/go-sql-driver/mysql v1.4.1 + github.com/go-sql-driver/mysql v1.6.0 github.com/jackc/pgx/v4 v4.6.0 github.com/joho/godotenv v1.3.0 - github.com/lib/pq v1.3.0 - github.com/mattn/go-sqlite3 v1.14.0 + github.com/lib/pq v1.10.0 + github.com/mattn/go-sqlite3 v1.14.7 github.com/spf13/pflag v1.0.5 - google.golang.org/appengine v1.3.0 // indirect - gopkg.in/yaml.v2 v2.2.7 + gopkg.in/yaml.v2 v2.4.0 ) go 1.13 diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/go.sum b/vendor/github.com/go-testfixtures/testfixtures/v3/go.sum index c118c8ef41..5af6a429d8 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/go.sum +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/go.sum @@ -1,5 +1,3 @@ -github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= -github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -10,14 +8,13 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73 h1:OGNva6WhsKst5OZf7eZOklDztV3hwtTHovdrLHV+MsA= github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= -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/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= @@ -72,16 +69,16 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -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/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E= +github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA= -github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= +github.com/mattn/go-sqlite3 v1.14.7 h1:fxWBnXkxfM6sRiuH3bqJ4CfzZojMOLVc0UTsTglEghA= +github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -114,23 +111,16 @@ go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= -golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -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-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -141,7 +131,6 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= @@ -152,13 +141,10 @@ golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk= -google.golang.org/appengine v1.3.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/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= -gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/mysql.go b/vendor/github.com/go-testfixtures/testfixtures/v3/mysql.go index c1cb720e4b..3f20fdb324 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/mysql.go +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/mysql.go @@ -7,6 +7,10 @@ import ( type mySQL struct { baseHelper + + skipResetSequences bool + resetSequencesTo int64 + tables []string tablesChecksum map[string]int64 } @@ -36,7 +40,7 @@ func (*mySQL) databaseName(q queryable) (string, error) { } func (h *mySQL) tableNames(q queryable) ([]string, error) { - query := ` + const query = ` SELECT table_name FROM information_schema.tables WHERE table_schema = ? @@ -69,6 +73,13 @@ func (h *mySQL) tableNames(q queryable) ([]string, error) { } func (h *mySQL) disableReferentialIntegrity(db *sql.DB, loadFn loadFunction) (err error) { + if !h.skipResetSequences { + defer func() { + if err2 := h.resetSequences(db); err2 != nil && err == nil { + err = err2 + } + }() + } tx, err := db.Begin() if err != nil { return err @@ -91,6 +102,20 @@ func (h *mySQL) disableReferentialIntegrity(db *sql.DB, loadFn loadFunction) (er return tx.Commit() } +func (h *mySQL) resetSequences(db *sql.DB) error { + resetSequencesTo := h.resetSequencesTo + if resetSequencesTo == 0 { + resetSequencesTo = 10000 + } + + for _, t := range h.tables { + if _, err := db.Exec(fmt.Sprintf("ALTER TABLE %s AUTO_INCREMENT = %d", h.quoteKeyword(t), resetSequencesTo)); err != nil { + return err + } + } + return nil +} + func (h *mySQL) isTableModified(q queryable, tableName string) (bool, error) { checksum, err := h.getChecksum(q, tableName) if err != nil { diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/postgresql.go b/vendor/github.com/go-testfixtures/testfixtures/v3/postgresql.go index 30064a02bd..3a3062e620 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/postgresql.go +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/postgresql.go @@ -66,7 +66,7 @@ func (*postgreSQL) databaseName(q queryable) (string, error) { func (h *postgreSQL) tableNames(q queryable) ([]string, error) { var tables []string - sql := ` + const sql = ` SELECT pg_namespace.nspname || '.' || pg_class.relname FROM pg_class INNER JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace @@ -126,7 +126,7 @@ func (h *postgreSQL) getSequences(q queryable) ([]string, error) { func (*postgreSQL) getNonDeferrableConstraints(q queryable) ([]pgConstraint, error) { var constraints []pgConstraint - sql := ` + const sql = ` SELECT table_schema || '.' || table_name, constraint_name FROM information_schema.table_constraints WHERE constraint_type = 'FOREIGN KEY' @@ -156,7 +156,7 @@ func (*postgreSQL) getNonDeferrableConstraints(q queryable) ([]pgConstraint, err func (h *postgreSQL) getConstraints(q queryable) ([]pgConstraint, error) { var constraints []pgConstraint - sql := ` + const sql = ` SELECT conrelid::regclass AS table_from, conname, pg_get_constraintdef(pg_constraint.oid) FROM pg_constraint INNER JOIN pg_namespace ON pg_namespace.oid = pg_constraint.connamespace @@ -192,29 +192,29 @@ func (h *postgreSQL) getConstraints(q queryable) ([]pgConstraint, error) { func (h *postgreSQL) dropAndRecreateConstraints(db *sql.DB, loadFn loadFunction) (err error) { defer func() { // Re-create constraints again after load - var sql string + var b strings.Builder for _, constraint := range h.constraints { - sql += fmt.Sprintf( + b.WriteString(fmt.Sprintf( "ALTER TABLE %s ADD CONSTRAINT %s %s;", h.quoteKeyword(constraint.tableName), h.quoteKeyword(constraint.constraintName), constraint.definition, - ) + )) } - if _, err2 := db.Exec(sql); err2 != nil && err == nil { + if _, err2 := db.Exec(b.String()); err2 != nil && err == nil { err = err2 } }() - var sql string + var b strings.Builder for _, constraint := range h.constraints { - sql += fmt.Sprintf( + b.WriteString(fmt.Sprintf( "ALTER TABLE %s DROP CONSTRAINT %s;", h.quoteKeyword(constraint.tableName), h.quoteKeyword(constraint.constraintName), - ) + )) } - if _, err := db.Exec(sql); err != nil { + if _, err := db.Exec(b.String()); err != nil { return err } @@ -233,12 +233,11 @@ func (h *postgreSQL) dropAndRecreateConstraints(db *sql.DB, loadFn loadFunction) func (h *postgreSQL) disableTriggers(db *sql.DB, loadFn loadFunction) (err error) { defer func() { - // re-enable triggers after load - var sql string + var b strings.Builder for _, table := range h.tables { - sql += fmt.Sprintf("ALTER TABLE %s ENABLE TRIGGER ALL;", h.quoteKeyword(table)) + b.WriteString(fmt.Sprintf("ALTER TABLE %s ENABLE TRIGGER ALL;", h.quoteKeyword(table))) } - if _, err2 := db.Exec(sql); err2 != nil && err == nil { + if _, err2 := db.Exec(b.String()); err2 != nil && err == nil { err = err2 } }() @@ -248,11 +247,11 @@ func (h *postgreSQL) disableTriggers(db *sql.DB, loadFn loadFunction) (err error return err } - var sql string + var b strings.Builder for _, table := range h.tables { - sql += fmt.Sprintf("ALTER TABLE %s DISABLE TRIGGER ALL;", h.quoteKeyword(table)) + b.WriteString(fmt.Sprintf("ALTER TABLE %s DISABLE TRIGGER ALL;", h.quoteKeyword(table))) } - if _, err = tx.Exec(sql); err != nil { + if _, err = tx.Exec(b.String()); err != nil { return err } @@ -267,20 +266,20 @@ func (h *postgreSQL) disableTriggers(db *sql.DB, loadFn loadFunction) (err error func (h *postgreSQL) makeConstraintsDeferrable(db *sql.DB, loadFn loadFunction) (err error) { defer func() { // ensure constraint being not deferrable again after load - var sql string + var b strings.Builder for _, constraint := range h.nonDeferrableConstraints { - sql += fmt.Sprintf("ALTER TABLE %s ALTER CONSTRAINT %s NOT DEFERRABLE;", h.quoteKeyword(constraint.tableName), h.quoteKeyword(constraint.constraintName)) + b.WriteString(fmt.Sprintf("ALTER TABLE %s ALTER CONSTRAINT %s NOT DEFERRABLE;", h.quoteKeyword(constraint.tableName), h.quoteKeyword(constraint.constraintName))) } - if _, err2 := db.Exec(sql); err2 != nil && err == nil { + if _, err2 := db.Exec(b.String()); err2 != nil && err == nil { err = err2 } }() - var sql string + var b strings.Builder for _, constraint := range h.nonDeferrableConstraints { - sql += fmt.Sprintf("ALTER TABLE %s ALTER CONSTRAINT %s DEFERRABLE;", h.quoteKeyword(constraint.tableName), h.quoteKeyword(constraint.constraintName)) + b.WriteString(fmt.Sprintf("ALTER TABLE %s ALTER CONSTRAINT %s DEFERRABLE;", h.quoteKeyword(constraint.tableName), h.quoteKeyword(constraint.constraintName))) } - if _, err := db.Exec(sql); err != nil { + if _, err := db.Exec(b.String()); err != nil { return err } diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/sqlserver.go b/vendor/github.com/go-testfixtures/testfixtures/v3/sqlserver.go index 9d6058ede6..bfd628b6a1 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/sqlserver.go +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/sqlserver.go @@ -114,20 +114,20 @@ func (h *sqlserver) whileInsertOnTable(tx *sql.Tx, tableName string, fn func() e func (h *sqlserver) disableReferentialIntegrity(db *sql.DB, loadFn loadFunction) (err error) { // ensure the triggers are re-enable after all defer func() { - var sql string + var b strings.Builder for _, table := range h.tables { - sql += fmt.Sprintf("ALTER TABLE %s WITH CHECK CHECK CONSTRAINT ALL;", h.quoteKeyword(table)) + b.WriteString(fmt.Sprintf("ALTER TABLE %s WITH CHECK CHECK CONSTRAINT ALL;", h.quoteKeyword(table))) } - if _, err2 := db.Exec(sql); err2 != nil && err == nil { + if _, err2 := db.Exec(b.String()); err2 != nil && err == nil { err = err2 } }() - var sql string + var b strings.Builder for _, table := range h.tables { - sql += fmt.Sprintf("ALTER TABLE %s NOCHECK CONSTRAINT ALL;", h.quoteKeyword(table)) + b.WriteString(fmt.Sprintf("ALTER TABLE %s NOCHECK CONSTRAINT ALL;", h.quoteKeyword(table))) } - if _, err := db.Exec(sql); err != nil { + if _, err := db.Exec(b.String()); err != nil { return err } diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go b/vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go index 87bec9f07a..f83359e0f8 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go @@ -159,14 +159,17 @@ func UseDropConstraint() func(*Loader) error { // SkipResetSequences prevents Loader from reseting sequences after loading // fixtures. // -// Only valid for PostgreSQL. Returns an error otherwise. +// Only valid for PostgreSQL and MySQL. Returns an error otherwise. func SkipResetSequences() func(*Loader) error { return func(l *Loader) error { - pgHelper, ok := l.helper.(*postgreSQL) - if !ok { - return fmt.Errorf("testfixtures: SkipResetSequences is only valid for PostgreSQL databases") + switch helper := l.helper.(type) { + case *postgreSQL: + helper.skipResetSequences = true + case *mySQL: + helper.skipResetSequences = true + default: + return fmt.Errorf("testfixtures: SkipResetSequences is valid for PostgreSQL and MySQL databases") } - pgHelper.skipResetSequences = true return nil } } @@ -175,14 +178,17 @@ func SkipResetSequences() func(*Loader) error { // // Defaults to 10000. // -// Only valid for PostgreSQL. Returns an error otherwise. +// Only valid for PostgreSQL and MySQL. Returns an error otherwise. func ResetSequencesTo(value int64) func(*Loader) error { return func(l *Loader) error { - pgHelper, ok := l.helper.(*postgreSQL) - if !ok { - return fmt.Errorf("testfixtures: ResetSequencesTo is only valid for PostgreSQL databases") + switch helper := l.helper.(type) { + case *postgreSQL: + helper.resetSequencesTo = value + case *mySQL: + helper.resetSequencesTo = value + default: + return fmt.Errorf("testfixtures: ResetSequencesTo is only valid for PostgreSQL and MySQL databases") } - pgHelper.resetSequencesTo = value return nil } } |