Fix scanning null values in timezone column

This commit is contained in:
Tulir Asokan 2022-05-12 20:51:37 +03:00
parent 8cb41b8949
commit c7b0f98f97
2 changed files with 3 additions and 2 deletions

View file

@ -90,16 +90,17 @@ type User struct {
}
func (user *User) Scan(row Scannable) *User {
var username sql.NullString
var username, timezone sql.NullString
var device, agent sql.NullByte
var phoneLastSeen, phoneLastPinged sql.NullInt64
err := row.Scan(&user.MXID, &username, &agent, &device, &user.ManagementRoom, &user.SpaceRoom, &phoneLastSeen, &phoneLastPinged, &user.Timezone)
err := row.Scan(&user.MXID, &username, &agent, &device, &user.ManagementRoom, &user.SpaceRoom, &phoneLastSeen, &phoneLastPinged, &timezone)
if err != nil {
if err != sql.ErrNoRows {
user.log.Errorln("Database scan failed:", err)
}
return nil
}
user.Timezone = timezone.String
if len(username.String) > 0 {
user.JID = types.NewADJID(username.String, agent.Byte, device.Byte)
}