From 39b11dbfb6f18c85ebe157ea9f85c7378c2cfb59 Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 26 Jun 2025 14:17:47 +0200 Subject: [bugfix] fix issues with postgres array serialization (#4295) thank you to @kipvandenbos -erino for figuring this out! Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4295 Co-authored-by: kim Co-committed-by: kim --- internal/db/bundb/migrations/util.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'internal/db/bundb/migrations/util.go') diff --git a/internal/db/bundb/migrations/util.go b/internal/db/bundb/migrations/util.go index f20f23c3f..4a3a62b21 100644 --- a/internal/db/bundb/migrations/util.go +++ b/internal/db/bundb/migrations/util.go @@ -34,10 +34,24 @@ import ( "github.com/uptrace/bun" "github.com/uptrace/bun/dialect" "github.com/uptrace/bun/dialect/feature" + "github.com/uptrace/bun/dialect/pgdialect" "github.com/uptrace/bun/dialect/sqltype" "github.com/uptrace/bun/schema" ) +// bunArrayType wraps the given type in a pgdialect.Array +// if needed, which postgres wants for serializing arrays. +func bunArrayType(db bun.IDB, arr any) any { + switch db.Dialect().Name() { + case dialect.SQLite: + return arr // return as-is + case dialect.PG: + return pgdialect.Array(arr) + default: + panic("unreachable") + } +} + // doWALCheckpoint attempt to force a WAL file merge on SQLite3, // which can be useful given how much can build-up in the WAL. // -- cgit v1.2.3