summaryrefslogtreecommitdiff
path: root/internal/db/bundb/upsert.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-04-16 13:10:13 +0200
committerLibravatar GitHub <noreply@github.com>2024-04-16 13:10:13 +0200
commit3cceed11b28b5f42a653d85ed779d652fd8c26ad (patch)
tree0a7f0994e477609ca705a45f382dfb62056b196e /internal/db/bundb/upsert.go
parent[performance] cached oauth database types (#2838) (diff)
downloadgotosocial-3cceed11b28b5f42a653d85ed779d652fd8c26ad.tar.xz
[feature/performance] Store account stats in separate table (#2831)
* [feature/performance] Store account stats in separate table, get stats from remote * test account stats * add some missing increment / decrement calls * change stats function signatures * rejig logging a bit * use lock when updating stats
Diffstat (limited to 'internal/db/bundb/upsert.go')
-rw-r--r--internal/db/bundb/upsert.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/db/bundb/upsert.go b/internal/db/bundb/upsert.go
index 34724446c..4a6395179 100644
--- a/internal/db/bundb/upsert.go
+++ b/internal/db/bundb/upsert.go
@@ -189,14 +189,14 @@ func (u *UpsertQuery) insertQuery() (*bun.InsertQuery, error) {
constraintIDPlaceholders = append(constraintIDPlaceholders, "?")
constraintIDs = append(constraintIDs, bun.Ident(constraint))
}
- onSQL := "conflict (" + strings.Join(constraintIDPlaceholders, ", ") + ") do update"
+ onSQL := "CONFLICT (" + strings.Join(constraintIDPlaceholders, ", ") + ") DO UPDATE"
setClauses := make([]string, 0, len(columns))
setIDs := make([]interface{}, 0, 2*len(columns))
for _, column := range columns {
+ setClauses = append(setClauses, "? = ?")
// "excluded" is a special table that contains only the row involved in a conflict.
- setClauses = append(setClauses, "? = excluded.?")
- setIDs = append(setIDs, bun.Ident(column), bun.Ident(column))
+ setIDs = append(setIDs, bun.Ident(column), bun.Ident("excluded."+column))
}
setSQL := strings.Join(setClauses, ", ")