Work on ensuring data consistency even for yet unknown fields
Some checks failed
/ docker (push) Has been cancelled

This commit is contained in:
Melody Becker 2025-05-28 16:52:54 +02:00
parent 7e10627618
commit bf0aaaca8f
Signed by: mstar
SSH key fingerprint: SHA256:9VAo09aaVNTWKzPW7Hq2LW+ox9OdwmTSHRoD4mlz1yI
12 changed files with 458 additions and 5 deletions

View file

@ -40,6 +40,7 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
_note.Quotes = field.NewField(tableName, "quotes")
_note.AccessLevel = field.NewField(tableName, "access_level")
_note.OriginId = field.NewUint(tableName, "origin_id")
_note.RawData = field.NewBytes(tableName, "raw_data")
_note.AttachmentRelations = noteHasManyAttachmentRelations{
db: db.Session(&gorm.Session{}),
@ -580,6 +581,7 @@ type note struct {
Quotes field.Field
AccessLevel field.Field
OriginId field.Uint
RawData field.Bytes
AttachmentRelations noteHasManyAttachmentRelations
EmoteRelations noteHasManyEmoteRelations
@ -621,6 +623,7 @@ func (n *note) updateTableName(table string) *note {
n.Quotes = field.NewField(table, "quotes")
n.AccessLevel = field.NewField(table, "access_level")
n.OriginId = field.NewUint(table, "origin_id")
n.RawData = field.NewBytes(table, "raw_data")
n.fillFieldMap()
@ -637,7 +640,7 @@ func (n *note) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
}
func (n *note) fillFieldMap() {
n.fieldMap = make(map[string]field.Expr, 19)
n.fieldMap = make(map[string]field.Expr, 20)
n.fieldMap["id"] = n.ID
n.fieldMap["created_at"] = n.CreatedAt
n.fieldMap["updated_at"] = n.UpdatedAt
@ -650,6 +653,7 @@ func (n *note) fillFieldMap() {
n.fieldMap["quotes"] = n.Quotes
n.fieldMap["access_level"] = n.AccessLevel
n.fieldMap["origin_id"] = n.OriginId
n.fieldMap["raw_data"] = n.RawData
}