mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-04-04 11:03:39 +00:00
Use pq arrays
This commit is contained in:
parent
2f41a4d2bf
commit
9f4ffe4c81
1 changed files with 10 additions and 1 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
|
@ -70,10 +71,14 @@ func UpStateBlocksRefactor(tx *sql.Tx) error {
|
|||
for snapshotrows.Next() {
|
||||
var snapshot types.StateSnapshotNID
|
||||
var room types.RoomNID
|
||||
var blocksarray pq.Int64Array
|
||||
var blocks []types.StateBlockNID
|
||||
if err = snapshotrows.Scan(&snapshot, &room, &blocks); err != nil {
|
||||
if err = snapshotrows.Scan(&snapshot, &room, &blocksarray); err != nil {
|
||||
return fmt.Errorf("rows.Scan: %w", err)
|
||||
}
|
||||
for _, b := range blocksarray {
|
||||
blocks = append(blocks, types.StateBlockNID(b))
|
||||
}
|
||||
|
||||
var newblocks []types.StateBlockNID
|
||||
for _, block := range blocks {
|
||||
|
@ -84,6 +89,7 @@ func UpStateBlocksRefactor(tx *sql.Tx) error {
|
|||
}
|
||||
defer internal.CloseAndLogIfError(context.TODO(), blockrows, "rows.close() failed")
|
||||
events := types.EventNIDs{}
|
||||
var eventsarray pq.Int64Array
|
||||
for blockrows.Next() {
|
||||
var event types.EventNID
|
||||
if err = blockrows.Scan(&event); err != nil {
|
||||
|
@ -91,6 +97,9 @@ func UpStateBlocksRefactor(tx *sql.Tx) error {
|
|||
}
|
||||
events = append(events, event)
|
||||
}
|
||||
for _, e := range eventsarray {
|
||||
events = append(events, types.EventNID(e))
|
||||
}
|
||||
events = events[:util.SortAndUnique(events)]
|
||||
|
||||
var blocknid types.StateBlockNID
|
||||
|
|
Loading…
Reference in a new issue