diff options
author | 2022-09-28 18:30:40 +0100 | |
---|---|---|
committer | 2022-09-28 18:30:40 +0100 | |
commit | a156188b3eb5cb3da44aa1b7452265f5fa38a607 (patch) | |
tree | 7097fa48d56fbabc7c2c8750b1f3bc9321d71c0f /vendor/github.com/uptrace/bun | |
parent | [bugfix] Fix emphasis being added to emoji shortcodes with markdown parsing (... (diff) | |
download | gotosocial-a156188b3eb5cb3da44aa1b7452265f5fa38a607.tar.xz |
[chore] update dependencies, bump to Go 1.19.1 (#826)
* update dependencies, bump Go version to 1.19
* bump test image Go version
* update golangci-lint
* update gotosocial-drone-build
* sign
* linting, go fmt
* update swagger docs
* update swagger docs
* whitespace
* update contributing.md
* fuckin whoopsie doopsie
* linterino, linteroni
* fix followrequest test not starting processor
* fix other api/client tests not starting processor
* fix remaining tests where processor not started
* bump go-runners version
* don't check last-webfingered-at, processor may have updated this
* update swagger command
* update bun to latest version
* fix embed to work the same as before with new bun
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
Diffstat (limited to 'vendor/github.com/uptrace/bun')
19 files changed, 211 insertions, 223 deletions
diff --git a/vendor/github.com/uptrace/bun/CHANGELOG.md b/vendor/github.com/uptrace/bun/CHANGELOG.md index 1738c901a..5271a43ca 100644 --- a/vendor/github.com/uptrace/bun/CHANGELOG.md +++ b/vendor/github.com/uptrace/bun/CHANGELOG.md @@ -1,3 +1,25 @@ +## [1.1.8](https://github.com/uptrace/bun/compare/v1.1.7...v1.1.8) (2022-08-29) + + +### Bug Fixes + +* **bunotel:** handle option attributes ([#656](https://github.com/uptrace/bun/issues/656)) ([9f1e0bd](https://github.com/uptrace/bun/commit/9f1e0bd19fc0300f12996b3e6595f093024e06b6)) +* driver.Valuer returns itself causes stackoverflow ([c9f51d3](https://github.com/uptrace/bun/commit/c9f51d3e2dabed0c29c26a4221abbc426a7206f3)), closes [#657](https://github.com/uptrace/bun/issues/657) +* **pgdriver:** return FATAL and PANIC errors immediately ([4595e38](https://github.com/uptrace/bun/commit/4595e385d3706116e47bf9dc295186ec7a2ab0f9)) +* quote m2m table name fixes [#649](https://github.com/uptrace/bun/issues/649) ([61a634e](https://github.com/uptrace/bun/commit/61a634e4cd5c18df4b75f756d4b0f06ea94bc3c8)) +* support multi-level embed column ([177ec4c](https://github.com/uptrace/bun/commit/177ec4c6e04f92957614ad4724bc82c422649a4b)), closes [#643](https://github.com/uptrace/bun/issues/643) + + +### Features + +* conditions not supporting composite in ([e5d78d4](https://github.com/uptrace/bun/commit/e5d78d464b94b78438cf275b4c35f713d129961d)) +* **idb:** support raw query ([be4e688](https://github.com/uptrace/bun/commit/be4e6886ad94b4b6ca42f24f73d79a15b1ac3188)) +* **migrate:** add MissingMigrations ([42567d0](https://github.com/uptrace/bun/commit/42567d052280f2c412d4796df7178915e537e6d9)) +* **pgdriver:** implement database/sql/driver.SessionResetter ([bda298a](https://github.com/uptrace/bun/commit/bda298ac66305e5b00ba67d72d3973625930c6b9)) +* **pgdriver:** provide access to the underlying net.Conn ([d07ea0e](https://github.com/uptrace/bun/commit/d07ea0ed1541225b5f08e59a4c87383811f7f051)) + + + ## [1.1.7](https://github.com/uptrace/bun/compare/v1.1.6...v1.1.7) (2022-07-29) diff --git a/vendor/github.com/uptrace/bun/Makefile b/vendor/github.com/uptrace/bun/Makefile index 690958de0..4961a8abf 100644 --- a/vendor/github.com/uptrace/bun/Makefile +++ b/vendor/github.com/uptrace/bun/Makefile @@ -11,12 +11,12 @@ test: done go_mod_tidy: - go get -u && go mod tidy -go=1.17 + go get -u && go mod tidy -go=1.18 set -e; for dir in $(ALL_GO_MOD_DIRS); do \ echo "go mod tidy in $${dir}"; \ (cd "$${dir}" && \ go get -u ./... && \ - go mod tidy -go=1.17); \ + go mod tidy -go=1.18); \ done fmt: diff --git a/vendor/github.com/uptrace/bun/README.md b/vendor/github.com/uptrace/bun/README.md index 0d1c2c6c2..c5c264f6b 100644 --- a/vendor/github.com/uptrace/bun/README.md +++ b/vendor/github.com/uptrace/bun/README.md @@ -34,209 +34,24 @@ Resources: - [Reference](https://pkg.go.dev/github.com/uptrace/bun) - [Starter kit](https://github.com/go-bun/bun-starter-kit) -Projects using Bun: +Featured projects using Bun: +- [uptrace](https://github.com/uptrace/uptrace) - Distributed tracing and metrics. +- [paralus](https://github.com/paralus/paralus) - All-in-one Kubernetes access manager. +- [inovex/scrumlr.io](https://github.com/inovex/scrumlr.io) - Webapp for collaborative online + retrospectives. - [gotosocial](https://github.com/superseriousbusiness/gotosocial) - Golang fediverse server. -- [alexedwards/scs](https://github.com/alexedwards/scs) - HTTP Session Management for Go. +- [lorawan-stack](https://github.com/TheThingsNetwork/lorawan-stack) - The Things Stack, an Open + Source LoRaWAN Network Server. +- [anti-phishing-bot](https://github.com/Benricheson101/anti-phishing-bot) - Discord bot for + deleting Steam/Discord phishing links. - [emerald-web3-gateway](https://github.com/oasisprotocol/emerald-web3-gateway) - Web3 Gateway for the Oasis Emerald paratime. - [lndhub.go](https://github.com/getAlby/lndhub.go) - accounting wrapper for the Lightning Network. -- [RealWorld app](https://github.com/go-bun/bun-realworld-app) -- And hundreds more. - -## Benchmark - -[https://github.com/davars/dbeval](https://github.com/davars/dbeval) - -<details> -<summary>results</summary> - -``` -BenchmarkInsert -BenchmarkInsert/*dbeval.Memory/Authors -BenchmarkInsert/*dbeval.Memory/Authors-4 84450 12104 ns/op 2623 B/op 70 allocs/op -BenchmarkInsert/*dbeval.Xorm/Authors -BenchmarkInsert/*dbeval.Xorm/Authors-4 7291 153505 ns/op 9024 B/op 311 allocs/op -BenchmarkInsert/*dbeval.UpperDB/Authors -BenchmarkInsert/*dbeval.UpperDB/Authors-4 4608 223672 ns/op 24160 B/op 1100 allocs/op -BenchmarkInsert/*dbeval.Bun/Authors -BenchmarkInsert/*dbeval.Bun/Authors-4 6034 186439 ns/op 6818 B/op 80 allocs/op -BenchmarkInsert/*dbeval.PQ/Authors -BenchmarkInsert/*dbeval.PQ/Authors-4 1141 907494 ns/op 6487 B/op 193 allocs/op -BenchmarkInsert/*dbeval.SQLX/Authors -BenchmarkInsert/*dbeval.SQLX/Authors-4 1165 916987 ns/op 10089 B/op 271 allocs/op -BenchmarkInsert/*dbeval.Ozzo/Authors -BenchmarkInsert/*dbeval.Ozzo/Authors-4 1105 1058082 ns/op 27826 B/op 588 allocs/op -BenchmarkInsert/*dbeval.PGXStdlib/Authors -BenchmarkInsert/*dbeval.PGXStdlib/Authors-4 1228 900207 ns/op 6032 B/op 180 allocs/op -BenchmarkInsert/*dbeval.Gorm/Authors -BenchmarkInsert/*dbeval.Gorm/Authors-4 946 1184285 ns/op 35634 B/op 918 allocs/op -BenchmarkInsert/*dbeval.PGX/Authors -BenchmarkInsert/*dbeval.PGX/Authors-4 1116 923728 ns/op 3839 B/op 130 allocs/op -BenchmarkInsert/*dbeval.DBR/Authors -BenchmarkInsert/*dbeval.DBR/Authors-4 5800 183982 ns/op 8646 B/op 230 allocs/op -BenchmarkInsert/*dbeval.GoPG/Authors -BenchmarkInsert/*dbeval.GoPG/Authors-4 6110 173923 ns/op 2906 B/op 87 allocs/op - -BenchmarkInsert/*dbeval.DBR/Articles -BenchmarkInsert/*dbeval.DBR/Articles-4 1706 684466 ns/op 133346 B/op 1614 allocs/op -BenchmarkInsert/*dbeval.PQ/Articles -BenchmarkInsert/*dbeval.PQ/Articles-4 884 1249791 ns/op 100403 B/op 1491 allocs/op -BenchmarkInsert/*dbeval.PGX/Articles -BenchmarkInsert/*dbeval.PGX/Articles-4 916 1288143 ns/op 83539 B/op 1392 allocs/op -BenchmarkInsert/*dbeval.GoPG/Articles -BenchmarkInsert/*dbeval.GoPG/Articles-4 1726 622639 ns/op 78638 B/op 1359 allocs/op -BenchmarkInsert/*dbeval.SQLX/Articles -BenchmarkInsert/*dbeval.SQLX/Articles-4 860 1262599 ns/op 92030 B/op 1574 allocs/op -BenchmarkInsert/*dbeval.Gorm/Articles -BenchmarkInsert/*dbeval.Gorm/Articles-4 782 1421550 ns/op 136534 B/op 2411 allocs/op -BenchmarkInsert/*dbeval.PGXStdlib/Articles -BenchmarkInsert/*dbeval.PGXStdlib/Articles-4 938 1230576 ns/op 86743 B/op 1441 allocs/op -BenchmarkInsert/*dbeval.Bun/Articles -BenchmarkInsert/*dbeval.Bun/Articles-4 1843 626681 ns/op 101610 B/op 1323 allocs/op -BenchmarkInsert/*dbeval.Xorm/Articles -BenchmarkInsert/*dbeval.Xorm/Articles-4 1677 650244 ns/op 126677 B/op 1752 allocs/op -BenchmarkInsert/*dbeval.Memory/Articles -BenchmarkInsert/*dbeval.Memory/Articles-4 1988 1223308 ns/op 77576 B/op 1310 allocs/op -BenchmarkInsert/*dbeval.UpperDB/Articles -BenchmarkInsert/*dbeval.UpperDB/Articles-4 1696 687130 ns/op 139680 B/op 2862 allocs/op -BenchmarkInsert/*dbeval.Ozzo/Articles -BenchmarkInsert/*dbeval.Ozzo/Articles-4 697 1496859 ns/op 114780 B/op 1950 allocs/op - -BenchmarkFindAuthorByID -BenchmarkFindAuthorByID/*dbeval.UpperDB -BenchmarkFindAuthorByID/*dbeval.UpperDB-4 10184 117527 ns/op 9953 B/op 441 allocs/op -BenchmarkFindAuthorByID/*dbeval.Bun -BenchmarkFindAuthorByID/*dbeval.Bun-4 20716 54261 ns/op 5096 B/op 15 allocs/op -BenchmarkFindAuthorByID/*dbeval.Ozzo -BenchmarkFindAuthorByID/*dbeval.Ozzo-4 11166 91043 ns/op 3088 B/op 64 allocs/op -BenchmarkFindAuthorByID/*dbeval.PQ -BenchmarkFindAuthorByID/*dbeval.PQ-4 13875 86171 ns/op 844 B/op 24 allocs/op -BenchmarkFindAuthorByID/*dbeval.PGX -BenchmarkFindAuthorByID/*dbeval.PGX-4 13846 79983 ns/op 719 B/op 15 allocs/op -BenchmarkFindAuthorByID/*dbeval.Memory -BenchmarkFindAuthorByID/*dbeval.Memory-4 14113720 82.33 ns/op 0 B/op 0 allocs/op -BenchmarkFindAuthorByID/*dbeval.Xorm -BenchmarkFindAuthorByID/*dbeval.Xorm-4 12027 98519 ns/op 3633 B/op 106 allocs/op -BenchmarkFindAuthorByID/*dbeval.Gorm -BenchmarkFindAuthorByID/*dbeval.Gorm-4 11521 102241 ns/op 6592 B/op 143 allocs/op -BenchmarkFindAuthorByID/*dbeval.PGXStdlib -BenchmarkFindAuthorByID/*dbeval.PGXStdlib-4 13933 82626 ns/op 1174 B/op 28 allocs/op -BenchmarkFindAuthorByID/*dbeval.DBR -BenchmarkFindAuthorByID/*dbeval.DBR-4 21920 51175 ns/op 1756 B/op 39 allocs/op -BenchmarkFindAuthorByID/*dbeval.SQLX -BenchmarkFindAuthorByID/*dbeval.SQLX-4 13603 80788 ns/op 1327 B/op 32 allocs/op -BenchmarkFindAuthorByID/*dbeval.GoPG -BenchmarkFindAuthorByID/*dbeval.GoPG-4 23174 50042 ns/op 869 B/op 17 allocs/op - -BenchmarkFindAuthorByName -BenchmarkFindAuthorByName/*dbeval.SQLX -BenchmarkFindAuthorByName/*dbeval.SQLX-4 1070 1065272 ns/op 126348 B/op 4018 allocs/op -BenchmarkFindAuthorByName/*dbeval.Bun -BenchmarkFindAuthorByName/*dbeval.Bun-4 877 1231377 ns/op 115803 B/op 5005 allocs/op -BenchmarkFindAuthorByName/*dbeval.Xorm -BenchmarkFindAuthorByName/*dbeval.Xorm-4 471 2345445 ns/op 455711 B/op 19080 allocs/op -BenchmarkFindAuthorByName/*dbeval.DBR -BenchmarkFindAuthorByName/*dbeval.DBR-4 954 1089977 ns/op 120070 B/op 6023 allocs/op -BenchmarkFindAuthorByName/*dbeval.PQ -BenchmarkFindAuthorByName/*dbeval.PQ-4 1333 784400 ns/op 87159 B/op 4006 allocs/op -BenchmarkFindAuthorByName/*dbeval.GoPG -BenchmarkFindAuthorByName/*dbeval.GoPG-4 1580 770966 ns/op 87525 B/op 3028 allocs/op -BenchmarkFindAuthorByName/*dbeval.UpperDB -BenchmarkFindAuthorByName/*dbeval.UpperDB-4 789 1314164 ns/op 190689 B/op 6428 allocs/op -BenchmarkFindAuthorByName/*dbeval.Ozzo -BenchmarkFindAuthorByName/*dbeval.Ozzo-4 948 1255282 ns/op 238764 B/op 6053 allocs/op -BenchmarkFindAuthorByName/*dbeval.PGXStdlib -BenchmarkFindAuthorByName/*dbeval.PGXStdlib-4 1279 920391 ns/op 126163 B/op 4014 allocs/op -BenchmarkFindAuthorByName/*dbeval.PGX -BenchmarkFindAuthorByName/*dbeval.PGX-4 1364 780970 ns/op 101967 B/op 2028 allocs/op -BenchmarkFindAuthorByName/*dbeval.Gorm -BenchmarkFindAuthorByName/*dbeval.Gorm-4 340 3445818 ns/op 1573637 B/op 27102 allocs/op -BenchmarkFindAuthorByName/*dbeval.Memory -BenchmarkFindAuthorByName/*dbeval.Memory-4 38081223 31.24 ns/op 0 B/op 0 allocs/op - -BenchmarkRecentArticles -BenchmarkRecentArticles/*dbeval.PGXStdlib -BenchmarkRecentArticles/*dbeval.PGXStdlib-4 358 3344119 ns/op 3425578 B/op 14177 allocs/op -BenchmarkRecentArticles/*dbeval.GoPG -BenchmarkRecentArticles/*dbeval.GoPG-4 364 3156372 ns/op 1794091 B/op 10032 allocs/op -BenchmarkRecentArticles/*dbeval.Xorm -BenchmarkRecentArticles/*dbeval.Xorm-4 157 7567835 ns/op 5018011 B/op 81425 allocs/op -BenchmarkRecentArticles/*dbeval.Gorm -BenchmarkRecentArticles/*dbeval.Gorm-4 139 7980084 ns/op 6776277 B/op 85418 allocs/op -BenchmarkRecentArticles/*dbeval.SQLX -BenchmarkRecentArticles/*dbeval.SQLX-4 338 3289802 ns/op 3425890 B/op 14181 allocs/op -BenchmarkRecentArticles/*dbeval.Ozzo -BenchmarkRecentArticles/*dbeval.Ozzo-4 320 3508322 ns/op 4025966 B/op 18207 allocs/op -BenchmarkRecentArticles/*dbeval.DBR -BenchmarkRecentArticles/*dbeval.DBR-4 237 5248644 ns/op 3331003 B/op 21370 allocs/op -BenchmarkRecentArticles/*dbeval.Bun -BenchmarkRecentArticles/*dbeval.Bun-4 280 4528582 ns/op 1864362 B/op 15965 allocs/op -BenchmarkRecentArticles/*dbeval.UpperDB -BenchmarkRecentArticles/*dbeval.UpperDB-4 297 3704663 ns/op 3607287 B/op 18542 allocs/op -BenchmarkRecentArticles/*dbeval.PQ -BenchmarkRecentArticles/*dbeval.PQ-4 308 3489229 ns/op 3277050 B/op 17359 allocs/op -BenchmarkRecentArticles/*dbeval.Memory -BenchmarkRecentArticles/*dbeval.Memory-4 29590380 42.27 ns/op 0 B/op 0 allocs/op -BenchmarkRecentArticles/*dbeval.PGX -BenchmarkRecentArticles/*dbeval.PGX-4 356 3345500 ns/op 3297316 B/op 6226 allocs/op -``` - -</details> - -[https://github.com/frederikhors/orm-benchmark](https://github.com/frederikhors/orm-benchmark) - -<details> -<summary>results</summary> - -``` - 4000 times - Insert - raw_stmt: 0.38s 94280 ns/op 718 B/op 14 allocs/op - raw: 0.39s 96719 ns/op 718 B/op 13 allocs/op - beego_orm: 0.48s 118994 ns/op 2411 B/op 56 allocs/op - bun: 0.57s 142285 ns/op 918 B/op 12 allocs/op - pg: 0.58s 145496 ns/op 1235 B/op 12 allocs/op - gorm: 0.70s 175294 ns/op 6665 B/op 88 allocs/op - xorm: 0.76s 189533 ns/op 3032 B/op 94 allocs/op - - 4000 times - MultiInsert 100 row - raw: 4.59s 1147385 ns/op 135155 B/op 916 allocs/op - raw_stmt: 4.59s 1148137 ns/op 131076 B/op 916 allocs/op - beego_orm: 5.50s 1375637 ns/op 179962 B/op 2747 allocs/op - bun: 6.18s 1544648 ns/op 4265 B/op 214 allocs/op - pg: 7.01s 1753495 ns/op 5039 B/op 114 allocs/op - gorm: 9.52s 2379219 ns/op 293956 B/op 3729 allocs/op - xorm: 11.66s 2915478 ns/op 286140 B/op 7422 allocs/op - - 4000 times - Update - raw_stmt: 0.26s 65781 ns/op 773 B/op 14 allocs/op - raw: 0.31s 77209 ns/op 757 B/op 13 allocs/op - beego_orm: 0.43s 107064 ns/op 1802 B/op 47 allocs/op - bun: 0.56s 139839 ns/op 589 B/op 4 allocs/op - pg: 0.60s 149608 ns/op 896 B/op 11 allocs/op - gorm: 0.74s 185970 ns/op 6604 B/op 81 allocs/op - xorm: 0.81s 203240 ns/op 2994 B/op 119 allocs/op - - 4000 times - Read - raw: 0.33s 81671 ns/op 2081 B/op 49 allocs/op - raw_stmt: 0.34s 85847 ns/op 2112 B/op 50 allocs/op - beego_orm: 0.38s 94777 ns/op 2106 B/op 75 allocs/op - pg: 0.42s 106148 ns/op 1526 B/op 22 allocs/op - bun: 0.43s 106904 ns/op 1319 B/op 18 allocs/op - gorm: 0.65s 162221 ns/op 5240 B/op 108 allocs/op - xorm: 1.13s 281738 ns/op 8326 B/op 237 allocs/op - - 4000 times - MultiRead limit 100 - raw: 1.52s 380351 ns/op 38356 B/op 1037 allocs/op - raw_stmt: 1.54s 385541 ns/op 38388 B/op 1038 allocs/op - pg: 1.86s 465468 ns/op 24045 B/op 631 allocs/op - bun: 2.58s 645354 ns/op 30009 B/op 1122 allocs/op - beego_orm: 2.93s 732028 ns/op 55280 B/op 3077 allocs/op - gorm: 4.97s 1241831 ns/op 71628 B/op 3877 allocs/op - xorm: doesn't work -``` - -</details> +- [penguin-statistics](https://github.com/penguin-statistics/backend-next) - Penguin Statistics v3 + Backend. +- And + [hundreds more](https://github.com/uptrace/bun/network/dependents?package_id=UGFja2FnZS0yMjkxOTc4OTA4). ## Why another database client? diff --git a/vendor/github.com/uptrace/bun/db.go b/vendor/github.com/uptrace/bun/db.go index 47e654655..9b8e391dc 100644 --- a/vendor/github.com/uptrace/bun/db.go +++ b/vendor/github.com/uptrace/bun/db.go @@ -98,6 +98,10 @@ func (db *DB) NewDelete() *DeleteQuery { return NewDeleteQuery(db) } +func (db *DB) NewRaw(query string, args ...interface{}) *RawQuery { + return NewRawQuery(db, query, args...) +} + func (db *DB) NewCreateTable() *CreateTableQuery { return NewCreateTableQuery(db) } @@ -342,6 +346,10 @@ func (c Conn) NewDelete() *DeleteQuery { return NewDeleteQuery(c.db).Conn(c) } +func (c Conn) NewRaw(query string, args ...interface{}) *RawQuery { + return NewRawQuery(c.db, query, args...).Conn(c) +} + func (c Conn) NewCreateTable() *CreateTableQuery { return NewCreateTableQuery(c.db).Conn(c) } @@ -648,6 +656,10 @@ func (tx Tx) NewDelete() *DeleteQuery { return NewDeleteQuery(tx.db).Conn(tx) } +func (tx Tx) NewRaw(query string, args ...interface{}) *RawQuery { + return NewRawQuery(tx.db, query, args...).Conn(tx) +} + func (tx Tx) NewCreateTable() *CreateTableQuery { return NewCreateTableQuery(tx.db).Conn(tx) } diff --git a/vendor/github.com/uptrace/bun/dialect/feature/feature.go b/vendor/github.com/uptrace/bun/dialect/feature/feature.go index 956dc4985..e311394d5 100644 --- a/vendor/github.com/uptrace/bun/dialect/feature/feature.go +++ b/vendor/github.com/uptrace/bun/dialect/feature/feature.go @@ -31,4 +31,5 @@ const ( UpdateFromTable MSSavepoint GeneratedIdentity + CompositeIn // ... WHERE (A,B) IN ((N, NN), (N, NN)...) ) diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go index d524f0a1a..6ff85e166 100644 --- a/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go +++ b/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go @@ -47,7 +47,8 @@ func New() *Dialect { feature.TableNotExists | feature.InsertOnConflict | feature.SelectExists | - feature.GeneratedIdentity + feature.GeneratedIdentity | + feature.CompositeIn return d } diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go index 8ab18b7a7..60837dd40 100644 --- a/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go +++ b/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go @@ -2,5 +2,5 @@ package pgdialect // Version is the current release version. func Version() string { - return "1.1.7" + return "1.1.8" } diff --git a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go index e79dcb004..720e979f5 100644 --- a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go +++ b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go @@ -38,7 +38,8 @@ func New() *Dialect { feature.DeleteTableAlias | feature.InsertOnConflict | feature.TableNotExists | - feature.SelectExists + feature.SelectExists | + feature.CompositeIn return d } diff --git a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go index 8f9def8d0..af57055cf 100644 --- a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go +++ b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go @@ -2,5 +2,5 @@ package sqlitedialect // Version is the current release version. func Version() string { - return "1.1.7" + return "1.1.8" } diff --git a/vendor/github.com/uptrace/bun/migrate/migration.go b/vendor/github.com/uptrace/bun/migrate/migration.go index ae649446d..a581098a3 100644 --- a/vendor/github.com/uptrace/bun/migrate/migration.go +++ b/vendor/github.com/uptrace/bun/migrate/migration.go @@ -18,6 +18,7 @@ type Migration struct { ID int64 `bun:",pk,autoincrement"` Name string + Comment string `bun:"-"` GroupID int64 MigratedAt time.Time `bun:",notnull,nullzero,default:current_timestamp"` @@ -26,7 +27,7 @@ type Migration struct { } func (m Migration) String() string { - return m.Name + return fmt.Sprintf("%s_%s", m.Name, m.Comment) } func (m Migration) IsApplied() bool { diff --git a/vendor/github.com/uptrace/bun/migrate/migrations.go b/vendor/github.com/uptrace/bun/migrate/migrations.go index 9af861048..0e26a09cc 100644 --- a/vendor/github.com/uptrace/bun/migrate/migrations.go +++ b/vendor/github.com/uptrace/bun/migrate/migrations.go @@ -50,15 +50,16 @@ func (m *Migrations) MustRegister(up, down MigrationFunc) { func (m *Migrations) Register(up, down MigrationFunc) error { fpath := migrationFile() - name, err := extractMigrationName(fpath) + name, comment, err := extractMigrationName(fpath) if err != nil { return err } m.Add(Migration{ - Name: name, - Up: up, - Down: down, + Name: name, + Comment: comment, + Up: up, + Down: down, }) return nil @@ -89,7 +90,7 @@ func (m *Migrations) Discover(fsys fs.FS) error { return nil } - name, err := extractMigrationName(path) + name, comment, err := extractMigrationName(path) if err != nil { return err } @@ -98,6 +99,8 @@ func (m *Migrations) Discover(fsys fs.FS) error { if err != nil { return err } + + migration.Comment = comment migrationFunc := NewSQLMigrationFunc(fsys, path) if strings.HasSuffix(path, ".up.sql") { @@ -154,15 +157,15 @@ func migrationFile() string { return "" } -var fnameRE = regexp.MustCompile(`^(\d{14})_[0-9a-z_\-]+\.`) +var fnameRE = regexp.MustCompile(`^(\d{14})_([0-9a-z_\-]+)\.`) -func extractMigrationName(fpath string) (string, error) { +func extractMigrationName(fpath string) (string, string, error) { fname := filepath.Base(fpath) matches := fnameRE.FindStringSubmatch(fname) if matches == nil { - return "", fmt.Errorf("migrate: unsupported migration name format: %q", fname) + return "", "", fmt.Errorf("migrate: unsupported migration name format: %q", fname) } - return matches[1], nil + return matches[1], matches[2], nil } diff --git a/vendor/github.com/uptrace/bun/migrate/migrator.go b/vendor/github.com/uptrace/bun/migrate/migrator.go index d0efca2fc..98d8f434e 100644 --- a/vendor/github.com/uptrace/bun/migrate/migrator.go +++ b/vendor/github.com/uptrace/bun/migrate/migrator.go @@ -74,7 +74,7 @@ func (m *Migrator) MigrationsWithStatus(ctx context.Context) (MigrationSlice, er func (m *Migrator) migrationsWithStatus(ctx context.Context) (MigrationSlice, int64, error) { sorted := m.migrations.Sorted() - applied, err := m.selectAppliedMigrations(ctx) + applied, err := m.AppliedMigrations(ctx) if err != nil { return nil, 0, err } @@ -338,8 +338,31 @@ func (m *Migrator) MarkUnapplied(ctx context.Context, migration *Migration) erro return err } -// selectAppliedMigrations selects applied (applied) migrations in descending order. -func (m *Migrator) selectAppliedMigrations(ctx context.Context) (MigrationSlice, error) { +func (m *Migrator) TruncateTable(ctx context.Context) error { + _, err := m.db.NewTruncateTable().TableExpr(m.table).Exec(ctx) + return err +} + +// MissingMigrations returns applied migrations that can no longer be found. +func (m *Migrator) MissingMigrations(ctx context.Context) (MigrationSlice, error) { + applied, err := m.AppliedMigrations(ctx) + if err != nil { + return nil, err + } + + existing := migrationMap(m.migrations.ms) + for i := len(applied) - 1; i >= 0; i-- { + m := &applied[i] + if _, ok := existing[m.Name]; ok { + applied = append(applied[:i], applied[i+1:]...) + } + } + + return applied, nil +} + +// AppliedMigrations selects applied (applied) migrations in descending order. +func (m *Migrator) AppliedMigrations(ctx context.Context) (MigrationSlice, error) { var ms MigrationSlice if err := m.db.NewSelect(). ColumnExpr("*"). diff --git a/vendor/github.com/uptrace/bun/package.json b/vendor/github.com/uptrace/bun/package.json index 9428ddcd5..de5f45a6a 100644 --- a/vendor/github.com/uptrace/bun/package.json +++ b/vendor/github.com/uptrace/bun/package.json @@ -1,6 +1,6 @@ { "name": "gobun", - "version": "1.1.7", + "version": "1.1.8", "main": "index.js", "repository": "git@github.com:uptrace/bun.git", "author": "Vladimir Mihailenco <vladimir.webdev@gmail.com>", diff --git a/vendor/github.com/uptrace/bun/query_base.go b/vendor/github.com/uptrace/bun/query_base.go index 45b77f028..b140ca24d 100644 --- a/vendor/github.com/uptrace/bun/query_base.go +++ b/vendor/github.com/uptrace/bun/query_base.go @@ -50,6 +50,7 @@ type IDB interface { NewInsert() *InsertQuery NewUpdate() *UpdateQuery NewDelete() *DeleteQuery + NewRaw(query string, args ...interface{}) *RawQuery NewCreateTable() *CreateTableQuery NewDropTable() *DropTableQuery NewCreateIndex() *CreateIndexQuery @@ -649,6 +650,10 @@ func (q *baseQuery) NewDelete() *DeleteQuery { return NewDeleteQuery(q.db).Conn(q.conn) } +func (q *baseQuery) NewRaw(query string, args ...interface{}) *RawQuery { + return NewRawQuery(q.db, query, args...).Conn(q.conn) +} + func (q *baseQuery) NewCreateTable() *CreateTableQuery { return NewCreateTableQuery(q.db).Conn(q.conn) } diff --git a/vendor/github.com/uptrace/bun/query_raw.go b/vendor/github.com/uptrace/bun/query_raw.go index 30ae77508..afbe12130 100644 --- a/vendor/github.com/uptrace/bun/query_raw.go +++ b/vendor/github.com/uptrace/bun/query_raw.go @@ -13,6 +13,7 @@ type RawQuery struct { args []interface{} } +// Deprecated: Use NewRaw instead. When add it to IDB, it conflicts with the sql.Conn#Raw func (db *DB) Raw(query string, args ...interface{}) *RawQuery { return &RawQuery{ baseQuery: baseQuery{ @@ -24,6 +25,22 @@ func (db *DB) Raw(query string, args ...interface{}) *RawQuery { } } +func NewRawQuery(db *DB, query string, args ...interface{}) *RawQuery { + return &RawQuery{ + baseQuery: baseQuery{ + db: db, + conn: db.DB, + }, + query: query, + args: args, + } +} + +func (q *RawQuery) Conn(db IConn) *RawQuery { + q.setConn(db) + return q +} + func (q *RawQuery) Scan(ctx context.Context, dest ...interface{}) error { if q.err != nil { return q.err diff --git a/vendor/github.com/uptrace/bun/relation_join.go b/vendor/github.com/uptrace/bun/relation_join.go index e8074e0c6..19dda774e 100644 --- a/vendor/github.com/uptrace/bun/relation_join.go +++ b/vendor/github.com/uptrace/bun/relation_join.go @@ -4,6 +4,7 @@ import ( "context" "reflect" + "github.com/uptrace/bun/dialect/feature" "github.com/uptrace/bun/internal" "github.com/uptrace/bun/schema" ) @@ -60,6 +61,14 @@ func (j *relationJoin) manyQuery(q *SelectQuery) *SelectQuery { q = q.Model(hasManyModel) var where []byte + + if q.db.dialect.Features().Has(feature.CompositeIn) { + return j.manyQueryCompositeIn(where, q) + } + return j.manyQueryMulti(where, q) +} + +func (j *relationJoin) manyQueryCompositeIn(where []byte, q *SelectQuery) *SelectQuery { if len(j.Relation.JoinFields) > 1 { where = append(where, '(') } @@ -88,6 +97,29 @@ func (j *relationJoin) manyQuery(q *SelectQuery) *SelectQuery { return q } +func (j *relationJoin) manyQueryMulti(where []byte, q *SelectQuery) *SelectQuery { + where = appendMultiValues( + q.db.Formatter(), + where, + j.JoinModel.rootValue(), + j.JoinModel.parentIndex(), + j.Relation.BaseFields, + j.Relation.JoinFields, + j.JoinModel.Table().SQLAlias, + ) + + q = q.Where(internal.String(where)) + + if j.Relation.PolymorphicField != nil { + q = q.Where("? = ?", j.Relation.PolymorphicField.SQLName, j.Relation.PolymorphicValue) + } + + j.applyTo(q) + q = q.Apply(j.hasManyColumns) + + return q +} + func (j *relationJoin) hasManyColumns(q *SelectQuery) *SelectQuery { b := make([]byte, 0, 32) @@ -151,7 +183,7 @@ func (j *relationJoin) m2mQuery(q *SelectQuery) *SelectQuery { //nolint var join []byte join = append(join, "JOIN "...) - join = fmter.AppendQuery(join, string(j.Relation.M2MTable.Name)) + join = fmter.AppendQuery(join, string(j.Relation.M2MTable.SQLName)) join = append(join, " AS "...) join = append(join, j.Relation.M2MTable.SQLAlias...) join = append(join, " ON ("...) @@ -312,3 +344,55 @@ func appendChildValues( } return b } + +// appendMultiValues is an alternative to appendChildValues that doesn't use the sql keyword ID +// but instead use a old style ((k1=v1) AND (k2=v2)) OR (...) of conditions. +func appendMultiValues( + fmter schema.Formatter, b []byte, v reflect.Value, index []int, baseFields, joinFields []*schema.Field, joinTable schema.Safe, +) []byte { + // This is based on a mix of appendChildValues and query_base.appendColumns + + // These should never missmatch in length but nice to know if it does + if len(joinFields) != len(baseFields) { + panic("not reached") + } + + // walk the relations + b = append(b, '(') + seen := make(map[string]struct{}) + walk(v, index, func(v reflect.Value) { + start := len(b) + for i, f := range baseFields { + if i > 0 { + b = append(b, " AND "...) + } + if len(baseFields) > 1 { + b = append(b, '(') + } + // Field name + b = append(b, joinTable...) + b = append(b, '.') + b = append(b, []byte(joinFields[i].SQLName)...) + + // Equals value + b = append(b, '=') + b = f.AppendValue(fmter, b, v) + if len(baseFields) > 1 { + b = append(b, ')') + } + } + + b = append(b, ") OR ("...) + + if _, ok := seen[string(b[start:])]; ok { + b = b[:start] + } else { + seen[string(b[start:])] = struct{}{} + } + }) + if len(seen) > 0 { + b = b[:len(b)-6] // trim ") OR (" + } + b = append(b, ')') + return b +} diff --git a/vendor/github.com/uptrace/bun/schema/append_value.go b/vendor/github.com/uptrace/bun/schema/append_value.go index 7e9c451db..93c892082 100644 --- a/vendor/github.com/uptrace/bun/schema/append_value.go +++ b/vendor/github.com/uptrace/bun/schema/append_value.go @@ -274,6 +274,9 @@ func appendDriverValue(fmter Formatter, b []byte, v reflect.Value) []byte { if err != nil { return dialect.AppendError(b, err) } + if _, ok := value.(driver.Valuer); ok { + return dialect.AppendError(b, fmt.Errorf("driver.Valuer returns unsupported type %T", value)) + } return Append(fmter, b, value) } diff --git a/vendor/github.com/uptrace/bun/schema/table.go b/vendor/github.com/uptrace/bun/schema/table.go index 9791f8ff1..ed8c517c1 100644 --- a/vendor/github.com/uptrace/bun/schema/table.go +++ b/vendor/github.com/uptrace/bun/schema/table.go @@ -287,17 +287,17 @@ func (t *Table) processBaseModelField(f reflect.StructField) { } } -//nolint +// nolint func (t *Table) newField(f reflect.StructField, prefix string, index []int) *Field { tag := tagparser.Parse(f.Tag.Get("bun")) - if prefix, ok := tag.Option("embed"); ok { + if nextPrefix, ok := tag.Option("embed"); ok { fieldType := indirectType(f.Type) if fieldType.Kind() != reflect.Struct { panic(fmt.Errorf("bun: embed %s.%s: got %s, wanted reflect.Struct", t.TypeName, f.Name, fieldType.Kind())) } - t.addFields(fieldType, prefix, withIndex(index, f.Index)) + t.addFields(fieldType, prefix+nextPrefix, withIndex(index, f.Index)) return nil } diff --git a/vendor/github.com/uptrace/bun/version.go b/vendor/github.com/uptrace/bun/version.go index 8d17c97b3..a9b3897c5 100644 --- a/vendor/github.com/uptrace/bun/version.go +++ b/vendor/github.com/uptrace/bun/version.go @@ -2,5 +2,5 @@ package bun // Version is the current release version. func Version() string { - return "1.1.7" + return "1.1.8" } |