mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 13:12:25 -06:00
[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>
This commit is contained in:
parent
700bd69828
commit
39b11dbfb6
4 changed files with 38 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue