Fix database statement not prepared

This commit is contained in:
Remi Reuvekamp 2017-10-15 00:36:31 +00:00
parent db88b4d9ab
commit 5c48d7316e
2 changed files with 6 additions and 3 deletions

View file

@ -85,6 +85,9 @@ func (s *devicesStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerN
if s.deleteDeviceStmt, err = db.Prepare(deleteDeviceSQL); err != nil {
return
}
if s.deleteDevicesByLocalpartStmt, err = db.Prepare(deleteDevicesByLocalpartSQL); err != nil {
return
}
s.serverName = server
return
}
@ -118,7 +121,7 @@ func (s *devicesStatements) deleteDevice(
func (s *devicesStatements) deleteDevicesByLocalpart(
ctx context.Context, txn *sql.Tx, localpart string,
) error {
stmt := common.TxStmt(txn, s.deleteDeviceStmt)
stmt := common.TxStmt(txn, s.deleteDevicesByLocalpartStmt)
_, err := stmt.ExecContext(ctx, localpart)
return err
}

View file

@ -111,8 +111,8 @@ func (d *Database) RemoveDevice(
}
// RemoveAllDevices revokes devices by deleting the entry in the
// database matching with the given user ID localpart.
// If something went wrong during the deletion, it will return the SQL error
// database matching the given user ID localpart.
// If something went wrong during the deletion, it will return the SQL error.
func (d *Database) RemoveAllDevices(
ctx context.Context, localpart string,
) error {