mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-19 01:53:01 -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
5
vendor/github.com/uptrace/bun/schema/field.go
generated
vendored
5
vendor/github.com/uptrace/bun/schema/field.go
generated
vendored
|
|
@ -32,6 +32,7 @@ type Field struct {
|
|||
NotNull bool
|
||||
NullZero bool
|
||||
AutoIncrement bool
|
||||
Identity bool
|
||||
|
||||
Append AppenderFunc
|
||||
Scan ScannerFunc
|
||||
|
|
@ -120,6 +121,10 @@ func (f *Field) ScanValue(strct reflect.Value, src interface{}) error {
|
|||
return f.ScanWithCheck(fv, src)
|
||||
}
|
||||
|
||||
func (f *Field) SkipUpdate() bool {
|
||||
return f.Tag.HasOption("skipupdate")
|
||||
}
|
||||
|
||||
func indexEqual(ind1, ind2 []int) bool {
|
||||
if len(ind1) != len(ind2) {
|
||||
return false
|
||||
|
|
|
|||
3
vendor/github.com/uptrace/bun/schema/relation.go
generated
vendored
3
vendor/github.com/uptrace/bun/schema/relation.go
generated
vendored
|
|
@ -18,6 +18,9 @@ type Relation struct {
|
|||
JoinTable *Table
|
||||
BaseFields []*Field
|
||||
JoinFields []*Field
|
||||
OnUpdate string
|
||||
OnDelete string
|
||||
Condition []string
|
||||
|
||||
PolymorphicField *Field
|
||||
PolymorphicValue string
|
||||
|
|
|
|||
5
vendor/github.com/uptrace/bun/schema/scan.go
generated
vendored
5
vendor/github.com/uptrace/bun/schema/scan.go
generated
vendored
|
|
@ -449,6 +449,11 @@ func PtrScanner(fn ScannerFunc) ScannerFunc {
|
|||
if dest.IsNil() {
|
||||
dest.Set(reflect.New(dest.Type().Elem()))
|
||||
}
|
||||
|
||||
if dest.Kind() == reflect.Map {
|
||||
return fn(dest, src)
|
||||
}
|
||||
|
||||
return fn(dest.Elem(), src)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
69
vendor/github.com/uptrace/bun/schema/table.go
generated
vendored
69
vendor/github.com/uptrace/bun/schema/table.go
generated
vendored
|
|
@ -353,6 +353,9 @@ func (t *Table) newField(f reflect.StructField, prefix string, index []int) *Fie
|
|||
field.AutoIncrement = true
|
||||
field.NullZero = true
|
||||
}
|
||||
if tag.HasOption("identity") {
|
||||
field.Identity = true
|
||||
}
|
||||
|
||||
if v, ok := tag.Options["unique"]; ok {
|
||||
var names []string
|
||||
|
|
@ -374,6 +377,7 @@ func (t *Table) newField(f reflect.StructField, prefix string, index []int) *Fie
|
|||
}
|
||||
if s, ok := tag.Option("default"); ok {
|
||||
field.SQLDefault = s
|
||||
field.NullZero = true
|
||||
}
|
||||
if s, ok := field.Tag.Option("type"); ok {
|
||||
field.UserSQLType = s
|
||||
|
|
@ -478,6 +482,39 @@ func (t *Table) belongsToRelation(field *Field) *Relation {
|
|||
JoinTable: joinTable,
|
||||
}
|
||||
|
||||
if field.Tag.HasOption("join_on") {
|
||||
rel.Condition = field.Tag.Options["join_on"]
|
||||
}
|
||||
|
||||
rel.OnUpdate = "ON UPDATE NO ACTION"
|
||||
if onUpdate, ok := field.Tag.Options["on_update"]; ok {
|
||||
if len(onUpdate) > 1 {
|
||||
panic(fmt.Errorf("bun: %s belongs-to %s: on_update option must be a single field", t.TypeName, field.GoName))
|
||||
}
|
||||
|
||||
rule := strings.ToUpper(onUpdate[0])
|
||||
if !isKnownFKRule(rule) {
|
||||
internal.Warn.Printf("bun: %s belongs-to %s: unknown on_update rule %s", t.TypeName, field.GoName, rule)
|
||||
}
|
||||
|
||||
s := fmt.Sprintf("ON UPDATE %s", rule)
|
||||
rel.OnUpdate = s
|
||||
}
|
||||
|
||||
rel.OnDelete = "ON DELETE NO ACTION"
|
||||
if onDelete, ok := field.Tag.Options["on_delete"]; ok {
|
||||
if len(onDelete) > 1 {
|
||||
panic(fmt.Errorf("bun: %s belongs-to %s: on_delete option must be a single field", t.TypeName, field.GoName))
|
||||
}
|
||||
|
||||
rule := strings.ToUpper(onDelete[0])
|
||||
if !isKnownFKRule(rule) {
|
||||
internal.Warn.Printf("bun: %s belongs-to %s: unknown on_delete rule %s", t.TypeName, field.GoName, rule)
|
||||
}
|
||||
s := fmt.Sprintf("ON DELETE %s", rule)
|
||||
rel.OnDelete = s
|
||||
}
|
||||
|
||||
if join, ok := field.Tag.Options["join"]; ok {
|
||||
baseColumns, joinColumns := parseRelationJoin(join)
|
||||
for i, baseColumn := range baseColumns {
|
||||
|
|
@ -539,6 +576,10 @@ func (t *Table) hasOneRelation(field *Field) *Relation {
|
|||
JoinTable: joinTable,
|
||||
}
|
||||
|
||||
if field.Tag.HasOption("join_on") {
|
||||
rel.Condition = field.Tag.Options["join_on"]
|
||||
}
|
||||
|
||||
if join, ok := field.Tag.Options["join"]; ok {
|
||||
baseColumns, joinColumns := parseRelationJoin(join)
|
||||
for i, baseColumn := range baseColumns {
|
||||
|
|
@ -605,6 +646,11 @@ func (t *Table) hasManyRelation(field *Field) *Relation {
|
|||
Field: field,
|
||||
JoinTable: joinTable,
|
||||
}
|
||||
|
||||
if field.Tag.HasOption("join_on") {
|
||||
rel.Condition = field.Tag.Options["join_on"]
|
||||
}
|
||||
|
||||
var polymorphicColumn string
|
||||
|
||||
if join, ok := field.Tag.Options["join"]; ok {
|
||||
|
|
@ -715,6 +761,11 @@ func (t *Table) m2mRelation(field *Field) *Relation {
|
|||
JoinTable: joinTable,
|
||||
M2MTable: m2mTable,
|
||||
}
|
||||
|
||||
if field.Tag.HasOption("join_on") {
|
||||
rel.Condition = field.Tag.Options["join_on"]
|
||||
}
|
||||
|
||||
var leftColumn, rightColumn string
|
||||
|
||||
if join, ok := field.Tag.Options["join"]; ok {
|
||||
|
|
@ -853,13 +904,29 @@ func isKnownFieldOption(name string) bool {
|
|||
"unique",
|
||||
"soft_delete",
|
||||
"scanonly",
|
||||
"skipupdate",
|
||||
|
||||
"pk",
|
||||
"autoincrement",
|
||||
"rel",
|
||||
"join",
|
||||
"join_on",
|
||||
"on_update",
|
||||
"on_delete",
|
||||
"m2m",
|
||||
"polymorphic":
|
||||
"polymorphic",
|
||||
"identity":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isKnownFKRule(name string) bool {
|
||||
switch name {
|
||||
case "CASCADE",
|
||||
"RESTRICT",
|
||||
"SET NULL",
|
||||
"SET DEFAULT":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue