mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-15 04:53:00 -06:00
[chore] Update bun / sqlite versions; update gtsmodels (#754)
* upstep bun and sqlite versions * allow specific columns to be updated in the db * only update necessary columns for user * bit tidier * only update necessary fields of media_attachment * only update relevant instance fields * update tests * update only specific account columns * use bool pointers on gtsmodels includes attachment, status, account, user * update columns more selectively * test all default fields on new account insert * updating remaining bools on gtsmodels * initialize pointer fields when extracting AP emoji * copy bools properly * add copyBoolPtr convenience function + test it * initialize false bool ptrs a bit more neatly
This commit is contained in:
parent
52fe681ba2
commit
ac6ed3d939
376 changed files with 337942 additions and 298092 deletions
64
vendor/github.com/uptrace/bun/query_update.go
generated
vendored
64
vendor/github.com/uptrace/bun/query_update.go
generated
vendored
|
|
@ -6,6 +6,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/uptrace/bun/dialect"
|
||||
|
||||
"github.com/uptrace/bun/dialect/feature"
|
||||
"github.com/uptrace/bun/internal"
|
||||
"github.com/uptrace/bun/schema"
|
||||
|
|
@ -16,6 +18,7 @@ type UpdateQuery struct {
|
|||
returningQuery
|
||||
customValueQuery
|
||||
setQuery
|
||||
idxHintsQuery
|
||||
|
||||
omitZero bool
|
||||
}
|
||||
|
|
@ -204,6 +207,11 @@ func (q *UpdateQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, e
|
|||
return nil, err
|
||||
}
|
||||
|
||||
b, err = q.appendIndexHints(fmter, b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, err = q.mustAppendSet(fmter, b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -273,7 +281,13 @@ func (q *UpdateQuery) appendSetStruct(
|
|||
isTemplate := fmter.IsNop()
|
||||
pos := len(b)
|
||||
for _, f := range fields {
|
||||
if q.omitZero && f.HasZeroValue(model.strct) {
|
||||
if f.SkipUpdate() {
|
||||
continue
|
||||
}
|
||||
|
||||
app, hasValue := q.modelValues[f.Name]
|
||||
|
||||
if !hasValue && q.omitZero && f.HasZeroValue(model.strct) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -290,8 +304,7 @@ func (q *UpdateQuery) appendSetStruct(
|
|||
continue
|
||||
}
|
||||
|
||||
app, ok := q.modelValues[f.Name]
|
||||
if ok {
|
||||
if hasValue {
|
||||
b, err = app.AppendQuery(fmter, b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -487,12 +500,32 @@ func (q *UpdateQuery) hasTableAlias(fmter schema.Formatter) bool {
|
|||
return fmter.HasFeature(feature.UpdateMultiTable | feature.UpdateTableAlias)
|
||||
}
|
||||
|
||||
func (q *UpdateQuery) String() string {
|
||||
buf, err := q.AppendQuery(q.db.Formatter(), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return string(buf)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
func (q *UpdateQuery) QueryBuilder() QueryBuilder {
|
||||
return &updateQueryBuilder{q}
|
||||
}
|
||||
|
||||
func (q *UpdateQuery) ApplyQueryBuilder(fn func(QueryBuilder) QueryBuilder) *UpdateQuery {
|
||||
return fn(q.QueryBuilder()).Unwrap().(*UpdateQuery)
|
||||
}
|
||||
|
||||
type updateQueryBuilder struct {
|
||||
*UpdateQuery
|
||||
}
|
||||
|
||||
func (q *updateQueryBuilder) WhereGroup(sep string, fn func(QueryBuilder) QueryBuilder) QueryBuilder {
|
||||
func (q *updateQueryBuilder) WhereGroup(
|
||||
sep string, fn func(QueryBuilder) QueryBuilder,
|
||||
) QueryBuilder {
|
||||
q.UpdateQuery = q.UpdateQuery.WhereGroup(sep, func(qs *UpdateQuery) *UpdateQuery {
|
||||
return fn(q).(*updateQueryBuilder).UpdateQuery
|
||||
})
|
||||
|
|
@ -528,6 +561,25 @@ func (q *updateQueryBuilder) Unwrap() interface{} {
|
|||
return q.UpdateQuery
|
||||
}
|
||||
|
||||
func (q *UpdateQuery) Query() QueryBuilder {
|
||||
return &updateQueryBuilder{q}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
func (q *UpdateQuery) UseIndex(indexes ...string) *UpdateQuery {
|
||||
if q.db.dialect.Name() == dialect.MySQL {
|
||||
q.addUseIndex(indexes...)
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
||||
func (q *UpdateQuery) IgnoreIndex(indexes ...string) *UpdateQuery {
|
||||
if q.db.dialect.Name() == dialect.MySQL {
|
||||
q.addIgnoreIndex(indexes...)
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
||||
func (q *UpdateQuery) ForceIndex(indexes ...string) *UpdateQuery {
|
||||
if q.db.dialect.Name() == dialect.MySQL {
|
||||
q.addForceIndex(indexes...)
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue