mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 20:32:26 -05: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
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