summaryrefslogtreecommitdiff
path: root/internal/db/bundb/util.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-06-26 14:17:47 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-06-26 14:17:47 +0200
commit39b11dbfb6f18c85ebe157ea9f85c7378c2cfb59 (patch)
tree7a071466d01bb0543dc7b57d1795f3db789056b2 /internal/db/bundb/util.go
parent[bugfix] move broken stage of filters migration into new migration (#4293) (diff)
downloadgotosocial-39b11dbfb6f18c85ebe157ea9f85c7378c2cfb59.tar.xz
[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 <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/db/bundb/util.go')
-rw-r--r--internal/db/bundb/util.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/db/bundb/util.go b/internal/db/bundb/util.go
index 6c743ffe9..d0d25a236 100644
--- a/internal/db/bundb/util.go
+++ b/internal/db/bundb/util.go
@@ -29,6 +29,7 @@ import (
"code.superseriousbusiness.org/gotosocial/internal/paging"
"github.com/uptrace/bun"
"github.com/uptrace/bun/dialect"
+ "github.com/uptrace/bun/dialect/pgdialect"
)
// likeEscaper is a thread-safe string replacer which escapes
@@ -60,6 +61,19 @@ func likeOperator(query *bun.SelectQuery) string {
return ""
}
+// 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")
+ }
+}
+
// whereLike appends a WHERE clause to the
// given SelectQuery, which searches for
// matches of `search` in the given subQuery