diff options
author | 2023-05-12 14:33:40 +0200 | |
---|---|---|
committer | 2023-05-12 14:33:40 +0200 | |
commit | ec325fee141c1e9757144a0a4094061b56839b78 (patch) | |
tree | 2948ab4ef5702cc8478ab2be841340b946bdb867 /vendor/github.com/uptrace | |
parent | [frogend/bugfix] fix dynamicSpoiler elements (#1771) (diff) | |
download | gotosocial-ec325fee141c1e9757144a0a4094061b56839b78.tar.xz |
[chore] Update a bunch of database dependencies (#1772)
* [chore] Update a bunch of database dependencies
* fix lil thing
Diffstat (limited to 'vendor/github.com/uptrace')
17 files changed, 129 insertions, 54 deletions
diff --git a/vendor/github.com/uptrace/bun/CHANGELOG.md b/vendor/github.com/uptrace/bun/CHANGELOG.md index 7350d15e3..89a473b5e 100644 --- a/vendor/github.com/uptrace/bun/CHANGELOG.md +++ b/vendor/github.com/uptrace/bun/CHANGELOG.md @@ -1,3 +1,24 @@ +## [1.1.13](https://github.com/uptrace/bun/compare/v1.1.12...v1.1.13) (2023-05-06) + + +### Bug Fixes + +* bunbig.Int.Scan typo ([7ddabb8](https://github.com/uptrace/bun/commit/7ddabb8c667f50032bc0bb2523a287efbe0851e7)) +* compare full MySQL version ([096fabe](https://github.com/uptrace/bun/commit/096fabefa114202d3601ad8e456f5e491a4e3787)) +* enable delete table alias for MySQL >= 8.0.16 ([77a600b](https://github.com/uptrace/bun/commit/77a600bc060154fb91aa68e68ba6a8875e5b10fb)) +* incorrect table relationship panic message [#791](https://github.com/uptrace/bun/issues/791) ([ad41888](https://github.com/uptrace/bun/commit/ad4188862eeaab30fc7c48d3224b5a786557aec5)) +* should rollback if migrate using transaction and got an err (thanks [@bayshark](https://github.com/bayshark)) ([e7a119b](https://github.com/uptrace/bun/commit/e7a119b1b8911d8bf059bb271c90ad4a5f5f02be)) + + +### Features + +* add option to customize Go migration template ([f31bf73](https://github.com/uptrace/bun/commit/f31bf739b9c7a0383411b9e67cba96c858795c68)) +* expose Exec(…) method for RawQuery ([11192c8](https://github.com/uptrace/bun/commit/11192c83f932eb7421ef09e06859a7f171de7803)) +* prefix migration files with 1 upto 14 digits ([b74b671](https://github.com/uptrace/bun/commit/b74b6714bb6a83e470e21801c97cc40e20acfb50)) +* rename option ([9353a3f](https://github.com/uptrace/bun/commit/9353a3f921c038fdf4a90665f1b0a9d0d03dc182)) + + + ## [1.1.12](https://github.com/uptrace/bun/compare/v1.1.11...v1.1.12) (2023-02-20) diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/append.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/append.go index 75798b385..7e9491abc 100644 --- a/vendor/github.com/uptrace/bun/dialect/pgdialect/append.go +++ b/vendor/github.com/uptrace/bun/dialect/pgdialect/append.go @@ -122,7 +122,8 @@ func (d *Dialect) arrayAppender(typ reflect.Type) schema.AppenderFunc { b = append(b, '\'') b = append(b, '{') - for i := 0; i < v.Len(); i++ { + ln := v.Len() + for i := 0; i < ln; i++ { elem := v.Index(i) b = appendElem(fmter, b, elem) b = append(b, ',') diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go index c3402a724..af2e0959f 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.12" + return "1.1.13" } diff --git a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go index d9d76cd90..aa3ed46f3 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.12" + return "1.1.13" } diff --git a/vendor/github.com/uptrace/bun/extra/bunotel/otel.go b/vendor/github.com/uptrace/bun/extra/bunotel/otel.go index 25000307d..95ca2a2b1 100644 --- a/vendor/github.com/uptrace/bun/extra/bunotel/otel.go +++ b/vendor/github.com/uptrace/bun/extra/bunotel/otel.go @@ -10,6 +10,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/global" "go.opentelemetry.io/otel/metric/instrument" semconv "go.opentelemetry.io/otel/semconv/v1.12.0" @@ -75,7 +76,8 @@ func (h *QueryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent) { } } - queryHistogram.Record(ctx, time.Since(event.StartTime).Milliseconds(), labels...) + dur := time.Since(event.StartTime) + queryHistogram.Record(ctx, dur.Milliseconds(), metric.WithAttributes(labels...)) span := trace.SpanFromContext(ctx) if !span.IsRecording() { diff --git a/vendor/github.com/uptrace/bun/migrate/migration.go b/vendor/github.com/uptrace/bun/migrate/migration.go index 6f395b7b4..1a4a67511 100644 --- a/vendor/github.com/uptrace/bun/migrate/migration.go +++ b/vendor/github.com/uptrace/bun/migrate/migration.go @@ -97,10 +97,15 @@ func Exec(ctx context.Context, db *bun.DB, f io.Reader, isTx bool) error { } var retErr error + var execErr error defer func() { if tx, ok := idb.(bun.Tx); ok { - retErr = tx.Commit() + if execErr != nil { + retErr = tx.Rollback() + } else { + retErr = tx.Commit() + } return } @@ -113,8 +118,9 @@ func Exec(ctx context.Context, db *bun.DB, f io.Reader, isTx bool) error { }() for _, q := range queries { - if _, err := idb.ExecContext(ctx, q); err != nil { - return err + _, execErr = idb.ExecContext(ctx, q) + if execErr != nil { + return execErr } } diff --git a/vendor/github.com/uptrace/bun/migrate/migrations.go b/vendor/github.com/uptrace/bun/migrate/migrations.go index 0e26a09cc..289735270 100644 --- a/vendor/github.com/uptrace/bun/migrate/migrations.go +++ b/vendor/github.com/uptrace/bun/migrate/migrations.go @@ -157,7 +157,7 @@ func migrationFile() string { return "" } -var fnameRE = regexp.MustCompile(`^(\d{14})_([0-9a-z_\-]+)\.`) +var fnameRE = regexp.MustCompile(`^(\d{1,14})_([0-9a-z_\-]+)\.`) func extractMigrationName(fpath string) (string, string, error) { fname := filepath.Base(fpath) diff --git a/vendor/github.com/uptrace/bun/migrate/migrator.go b/vendor/github.com/uptrace/bun/migrate/migrator.go index e24dba808..5cae6ccb9 100644 --- a/vendor/github.com/uptrace/bun/migrate/migrator.go +++ b/vendor/github.com/uptrace/bun/migrate/migrator.go @@ -217,6 +217,7 @@ func (m *Migrator) Rollback(ctx context.Context, opts ...MigrationOption) (*Migr type goMigrationConfig struct { packageName string + goTemplate string } type GoMigrationOption func(cfg *goMigrationConfig) @@ -227,12 +228,19 @@ func WithPackageName(name string) GoMigrationOption { } } +func WithGoTemplate(template string) GoMigrationOption { + return func(cfg *goMigrationConfig) { + cfg.goTemplate = template + } +} + // CreateGoMigration creates a Go migration file. func (m *Migrator) CreateGoMigration( ctx context.Context, name string, opts ...GoMigrationOption, ) (*MigrationFile, error) { cfg := &goMigrationConfig{ packageName: "migrations", + goTemplate: goTemplate, } for _, opt := range opts { opt(cfg) @@ -245,7 +253,7 @@ func (m *Migrator) CreateGoMigration( fname := name + ".go" fpath := filepath.Join(m.migrations.getDirectory(), fname) - content := fmt.Sprintf(goTemplate, cfg.packageName) + content := fmt.Sprintf(cfg.goTemplate, cfg.packageName) if err := ioutil.WriteFile(fpath, []byte(content), 0o644); err != nil { return nil, err diff --git a/vendor/github.com/uptrace/bun/model.go b/vendor/github.com/uptrace/bun/model.go index 6ad4d8efe..046bfdfea 100644 --- a/vendor/github.com/uptrace/bun/model.go +++ b/vendor/github.com/uptrace/bun/model.go @@ -101,7 +101,7 @@ func _newModel(db *DB, dest interface{}, scan bool) (Model, error) { if typ.Kind() == reflect.Struct { return newStructTableModel(db, dest, db.Table(typ)), nil } - return nil, fmt.Errorf("bun: Model(nil %T)", dest) + return nil, fmt.Errorf("bun: Model(nil %s %T)", typ.Kind(), dest) } v = v.Elem() diff --git a/vendor/github.com/uptrace/bun/package.json b/vendor/github.com/uptrace/bun/package.json index 6d62f597d..37f67cd1a 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.12", + "version": "1.1.13", "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 9df70d1f4..4b3545d0d 100644 --- a/vendor/github.com/uptrace/bun/query_base.go +++ b/vendor/github.com/uptrace/bun/query_base.go @@ -180,13 +180,13 @@ func (q *baseQuery) setErr(err error) { } func (q *baseQuery) getModel(dest []interface{}) (Model, error) { - if len(dest) == 0 { - if q.model != nil { - return q.model, nil - } - return nil, errNilModel + if len(dest) > 0 { + return newModel(q.db, dest) + } + if q.model != nil { + return q.model, nil } - return newModel(q.db, dest) + return nil, errNilModel } func (q *baseQuery) beforeAppendModel(ctx context.Context, query Query) error { @@ -1054,7 +1054,12 @@ type customValueQuery struct { func (q *customValueQuery) addValue( table *schema.Table, column string, value string, args []interface{}, ) { - if _, ok := table.FieldMap[column]; ok { + ok := false + if table != nil { + _, ok = table.FieldMap[column] + } + + if ok { if q.modelValues == nil { q.modelValues = make(map[string]schema.QueryWithArgs) } diff --git a/vendor/github.com/uptrace/bun/query_raw.go b/vendor/github.com/uptrace/bun/query_raw.go index 7afa4d536..fda088a7c 100644 --- a/vendor/github.com/uptrace/bun/query_raw.go +++ b/vendor/github.com/uptrace/bun/query_raw.go @@ -2,6 +2,7 @@ package bun import ( "context" + "database/sql" "github.com/uptrace/bun/schema" ) @@ -46,19 +47,46 @@ func (q *RawQuery) Err(err error) *RawQuery { return q } +func (q *RawQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) { + return q.scanOrExec(ctx, dest, len(dest) > 0) +} + func (q *RawQuery) Scan(ctx context.Context, dest ...interface{}) error { + _, err := q.scanOrExec(ctx, dest, true) + return err +} + +func (q *RawQuery) scanOrExec( + ctx context.Context, dest []interface{}, hasDest bool, +) (sql.Result, error) { if q.err != nil { - return q.err + return nil, q.err } - model, err := q.getModel(dest) - if err != nil { - return err + var model Model + var err error + + if hasDest { + model, err = q.getModel(dest) + if err != nil { + return nil, err + } } query := q.db.format(q.query, q.args) - _, err = q.scan(ctx, q, query, model, true) - return err + var res sql.Result + + if hasDest { + res, err = q.scan(ctx, q, query, model, hasDest) + } else { + res, err = q.exec(ctx, q, query) + } + + if err != nil { + return nil, err + } + + return res, nil } func (q *RawQuery) AppendQuery(fmter schema.Formatter, b []byte) ([]byte, error) { diff --git a/vendor/github.com/uptrace/bun/schema/append.go b/vendor/github.com/uptrace/bun/schema/append.go index 04538c036..6f633b101 100644 --- a/vendor/github.com/uptrace/bun/schema/append.go +++ b/vendor/github.com/uptrace/bun/schema/append.go @@ -79,6 +79,11 @@ func (in *inValues) AppendQuery(fmter Formatter, b []byte) (_ []byte, err error) func appendIn(fmter Formatter, b []byte, slice reflect.Value) []byte { sliceLen := slice.Len() + + if sliceLen == 0 { + return append(b, "NULL"...) + } + for i := 0; i < sliceLen; i++ { if i > 0 { b = append(b, ", "...) diff --git a/vendor/github.com/uptrace/bun/schema/table.go b/vendor/github.com/uptrace/bun/schema/table.go index ed8c517c1..9eb7d1bfe 100644 --- a/vendor/github.com/uptrace/bun/schema/table.go +++ b/vendor/github.com/uptrace/bun/schema/table.go @@ -534,7 +534,7 @@ func (t *Table) belongsToRelation(field *Field) *Relation { } else { panic(fmt.Errorf( "bun: %s belongs-to %s: %s must have column %s", - t.TypeName, field.GoName, t.TypeName, baseColumn, + t.TypeName, field.GoName, joinTable.TypeName, joinColumn, )) } } @@ -588,7 +588,7 @@ func (t *Table) hasOneRelation(field *Field) *Relation { } else { panic(fmt.Errorf( "bun: %s has-one %s: %s must have column %s", - field.GoName, t.TypeName, joinTable.TypeName, baseColumn, + field.GoName, t.TypeName, t.TypeName, baseColumn, )) } @@ -598,7 +598,7 @@ func (t *Table) hasOneRelation(field *Field) *Relation { } else { panic(fmt.Errorf( "bun: %s has-one %s: %s must have column %s", - field.GoName, t.TypeName, joinTable.TypeName, baseColumn, + field.GoName, t.TypeName, joinTable.TypeName, joinColumn, )) } } @@ -677,7 +677,7 @@ func (t *Table) hasManyRelation(field *Field) *Relation { } else { panic(fmt.Errorf( "bun: %s has-many %s: %s must have column %s", - t.TypeName, field.GoName, t.TypeName, baseColumn, + t.TypeName, field.GoName, joinTable.TypeName, joinColumn, )) } } diff --git a/vendor/github.com/uptrace/bun/version.go b/vendor/github.com/uptrace/bun/version.go index daa7f929d..790925f67 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.12" + return "1.1.13" } diff --git a/vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/otel.go b/vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/otel.go index 0932e2759..5a011ae5d 100644 --- a/vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/otel.go +++ b/vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/otel.go @@ -12,7 +12,6 @@ import ( "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/global" - "go.opentelemetry.io/otel/metric/instrument" semconv "go.opentelemetry.io/otel/semconv/v1.10.0" "go.opentelemetry.io/otel/trace" ) @@ -54,7 +53,7 @@ func (c *config) formatQuery(query string) string { type dbInstrum struct { *config - queryHistogram instrument.Int64Histogram + queryHistogram metric.Int64Histogram } func newDBInstrum(opts []Option) *dbInstrum { @@ -72,8 +71,8 @@ func newDBInstrum(opts []Option) *dbInstrum { var err error t.queryHistogram, err = t.meter.Int64Histogram( "go.sql.query_timing", - instrument.WithDescription("Timing of processed queries"), - instrument.WithUnit("milliseconds"), + metric.WithDescription("Timing of processed queries"), + metric.WithUnit("milliseconds"), ) if err != nil { panic(err) @@ -106,7 +105,7 @@ func (t *dbInstrum) withSpan( span.End() if query != "" { - t.queryHistogram.Record(ctx, time.Since(startTime).Milliseconds(), t.attrs...) + t.queryHistogram.Record(ctx, time.Since(startTime).Milliseconds(), metric.WithAttributes(t.attrs...)) } if !span.IsRecording() { @@ -185,57 +184,57 @@ func ReportDBStatsMetrics(db *sql.DB, opts ...Option) { maxOpenConns, _ := meter.Int64ObservableGauge( "go.sql.connections_max_open", - instrument.WithDescription("Maximum number of open connections to the database"), + metric.WithDescription("Maximum number of open connections to the database"), ) openConns, _ := meter.Int64ObservableGauge( "go.sql.connections_open", - instrument.WithDescription("The number of established connections both in use and idle"), + metric.WithDescription("The number of established connections both in use and idle"), ) inUseConns, _ := meter.Int64ObservableGauge( "go.sql.connections_in_use", - instrument.WithDescription("The number of connections currently in use"), + metric.WithDescription("The number of connections currently in use"), ) idleConns, _ := meter.Int64ObservableGauge( "go.sql.connections_idle", - instrument.WithDescription("The number of idle connections"), + metric.WithDescription("The number of idle connections"), ) connsWaitCount, _ := meter.Int64ObservableCounter( "go.sql.connections_wait_count", - instrument.WithDescription("The total number of connections waited for"), + metric.WithDescription("The total number of connections waited for"), ) connsWaitDuration, _ := meter.Int64ObservableCounter( "go.sql.connections_wait_duration", - instrument.WithDescription("The total time blocked waiting for a new connection"), - instrument.WithUnit("nanoseconds"), + metric.WithDescription("The total time blocked waiting for a new connection"), + metric.WithUnit("nanoseconds"), ) connsClosedMaxIdle, _ := meter.Int64ObservableCounter( "go.sql.connections_closed_max_idle", - instrument.WithDescription("The total number of connections closed due to SetMaxIdleConns"), + metric.WithDescription("The total number of connections closed due to SetMaxIdleConns"), ) connsClosedMaxIdleTime, _ := meter.Int64ObservableCounter( "go.sql.connections_closed_max_idle_time", - instrument.WithDescription("The total number of connections closed due to SetConnMaxIdleTime"), + metric.WithDescription("The total number of connections closed due to SetConnMaxIdleTime"), ) connsClosedMaxLifetime, _ := meter.Int64ObservableCounter( "go.sql.connections_closed_max_lifetime", - instrument.WithDescription("The total number of connections closed due to SetConnMaxLifetime"), + metric.WithDescription("The total number of connections closed due to SetConnMaxLifetime"), ) if _, err := meter.RegisterCallback( func(ctx context.Context, o metric.Observer) error { stats := db.Stats() - o.ObserveInt64(maxOpenConns, int64(stats.MaxOpenConnections), labels...) + o.ObserveInt64(maxOpenConns, int64(stats.MaxOpenConnections), metric.WithAttributes(labels...)) - o.ObserveInt64(openConns, int64(stats.OpenConnections), labels...) - o.ObserveInt64(inUseConns, int64(stats.InUse), labels...) - o.ObserveInt64(idleConns, int64(stats.Idle), labels...) + o.ObserveInt64(openConns, int64(stats.OpenConnections), metric.WithAttributes(labels...)) + o.ObserveInt64(inUseConns, int64(stats.InUse), metric.WithAttributes(labels...)) + o.ObserveInt64(idleConns, int64(stats.Idle), metric.WithAttributes(labels...)) - o.ObserveInt64(connsWaitCount, stats.WaitCount, labels...) - o.ObserveInt64(connsWaitDuration, int64(stats.WaitDuration), labels...) - o.ObserveInt64(connsClosedMaxIdle, stats.MaxIdleClosed, labels...) - o.ObserveInt64(connsClosedMaxIdleTime, stats.MaxIdleTimeClosed, labels...) - o.ObserveInt64(connsClosedMaxLifetime, stats.MaxLifetimeClosed, labels...) + o.ObserveInt64(connsWaitCount, stats.WaitCount, metric.WithAttributes(labels...)) + o.ObserveInt64(connsWaitDuration, int64(stats.WaitDuration), metric.WithAttributes(labels...)) + o.ObserveInt64(connsClosedMaxIdle, stats.MaxIdleClosed, metric.WithAttributes(labels...)) + o.ObserveInt64(connsClosedMaxIdleTime, stats.MaxIdleTimeClosed, metric.WithAttributes(labels...)) + o.ObserveInt64(connsClosedMaxLifetime, stats.MaxLifetimeClosed, metric.WithAttributes(labels...)) return nil }, diff --git a/vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/version.go b/vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/version.go index 97134301d..1c2291bc5 100644 --- a/vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/version.go +++ b/vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/version.go @@ -2,5 +2,5 @@ package otelsql // Version is the current release version. func Version() string { - return "0.1.21" + return "0.2.0" } |