mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 11:23:11 -06:00
Fix database queries
This commit is contained in:
parent
c3f8eeb50f
commit
eee88ba2ac
|
|
@ -45,5 +45,5 @@ type Database interface {
|
|||
GetMembership(ctx context.Context, roomNID types.RoomNID, requestSenderUserID string) (membershipEventNID types.EventNID, stillInRoom bool, err error)
|
||||
GetMembershipEventNIDsForRoom(ctx context.Context, roomNID types.RoomNID, joinOnly bool) ([]types.EventNID, error)
|
||||
EventsFromIDs(ctx context.Context, eventIDs []string) ([]types.Event, error)
|
||||
GetRoomVersionForRoom(ctx context.Context, roomNID types.RoomNID) (int64, error)
|
||||
GetRoomVersionForRoom(ctx context.Context, roomNID types.RoomNID) (gomatrixserverlib.RoomVersion, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/lib/pq"
|
||||
"github.com/matrix-org/dendrite/common"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
||||
const roomsSchema = `
|
||||
|
|
@ -165,8 +166,8 @@ func (s *roomStatements) updateLatestEventNIDs(
|
|||
|
||||
func (s *roomStatements) selectRoomVersionForRoomNID(
|
||||
ctx context.Context, txn *sql.Tx, roomNID types.RoomNID,
|
||||
) (int64, error) {
|
||||
var roomVersion int64
|
||||
) (gomatrixserverlib.RoomVersion, error) {
|
||||
var roomVersion gomatrixserverlib.RoomVersion
|
||||
stmt := common.TxStmt(txn, s.selectRoomVersionForRoomNIDStmt)
|
||||
err := stmt.QueryRowContext(ctx, roomNID).Scan(&roomVersion)
|
||||
return roomVersion, err
|
||||
|
|
|
|||
|
|
@ -699,7 +699,7 @@ func (d *Database) EventsFromIDs(ctx context.Context, eventIDs []string) ([]type
|
|||
|
||||
func (d *Database) GetRoomVersionForRoom(
|
||||
ctx context.Context, roomNID types.RoomNID,
|
||||
) (int64, error) {
|
||||
) (gomatrixserverlib.RoomVersion, error) {
|
||||
return d.statements.selectRoomVersionForRoomNID(
|
||||
ctx, nil, roomNID,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
|
||||
"github.com/matrix-org/dendrite/common"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
||||
const roomsSchema = `
|
||||
|
|
@ -157,8 +158,8 @@ func (s *roomStatements) updateLatestEventNIDs(
|
|||
|
||||
func (s *roomStatements) selectRoomVersionForRoomNID(
|
||||
ctx context.Context, txn *sql.Tx, roomNID types.RoomNID,
|
||||
) (int64, error) {
|
||||
var roomVersion int64
|
||||
) (gomatrixserverlib.RoomVersion, error) {
|
||||
var roomVersion gomatrixserverlib.RoomVersion
|
||||
stmt := common.TxStmt(txn, s.selectRoomVersionForRoomNIDStmt)
|
||||
err := stmt.QueryRowContext(ctx, roomNID).Scan(&roomVersion)
|
||||
return roomVersion, err
|
||||
|
|
|
|||
|
|
@ -853,7 +853,7 @@ func (d *Database) EventsFromIDs(ctx context.Context, eventIDs []string) ([]type
|
|||
|
||||
func (d *Database) GetRoomVersionForRoom(
|
||||
ctx context.Context, roomNID types.RoomNID,
|
||||
) (int64, error) {
|
||||
) (gomatrixserverlib.RoomVersion, error) {
|
||||
return d.statements.selectRoomVersionForRoomNID(
|
||||
ctx, nil, roomNID,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue