From 10ccd50df0efca7ba58304a64405b0194d82e347 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Fri, 28 Oct 2022 14:59:23 +0200 Subject: [PATCH] Testing --- .../storage/postgres/state_block_table.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/roomserver/storage/postgres/state_block_table.go b/roomserver/storage/postgres/state_block_table.go index 5af48f031..5b728e5f9 100644 --- a/roomserver/storage/postgres/state_block_table.go +++ b/roomserver/storage/postgres/state_block_table.go @@ -16,16 +16,19 @@ package postgres import ( + "bytes" "context" "database/sql" "fmt" + "strconv" "github.com/lib/pq" + "github.com/matrix-org/util" + "github.com/matrix-org/dendrite/internal" "github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/roomserver/storage/tables" "github.com/matrix-org/dendrite/roomserver/types" - "github.com/matrix-org/util" ) const stateDataSchema = ` @@ -113,14 +116,20 @@ func (s *stateBlockStatements) BulkSelectStateBlockEntries( results := make([][]types.EventNID, len(stateBlockNIDs)) i := 0 var stateBlockNID types.StateBlockNID - var result pq.Int64Array + var result []byte + var parsed int64 for ; rows.Next(); i++ { if err = rows.Scan(&stateBlockNID, &result); err != nil { return nil, err } - r := make([]types.EventNID, len(result)) - for x := range result { - r[x] = types.EventNID(result[x]) + split := bytes.Split(result[1:len(result)-1], []byte(",")) + r := make([]types.EventNID, len(split)) + for x, y := range split { + parsed, err = strconv.ParseInt(string(y), 10, 64) + if err != nil { + return nil, err + } + r[x] = types.EventNID(parsed) } results[i] = r }