From 2378476fe5c630dcc7efa8aab0b8da5aa12a9014 Mon Sep 17 00:00:00 2001 From: Christopher Schinnerl Date: Tue, 18 Jun 2024 16:50:56 +0200 Subject: [PATCH] Make sure types implement Scanner and Valuer (#1319) Not really a fix but better safe than sorry --- stores/sql/types.go | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/stores/sql/types.go b/stores/sql/types.go index 1ac27f8a5..1e67b49c0 100644 --- a/stores/sql/types.go +++ b/stores/sql/types.go @@ -35,12 +35,24 @@ type ( Unsigned64 uint64 ) +type scannerValuer interface { + driver.Valuer + sql.Scanner +} + var ( - _ sql.Scanner = &Currency{} - _ sql.Scanner = &FileContractID{} - _ sql.Scanner = &Hash256{} - _ sql.Scanner = &PublicKey{} - _ sql.Scanner = &SecretKey{} + _ scannerValuer = (*AutopilotConfig)(nil) + _ scannerValuer = (*BigInt)(nil) + _ scannerValuer = (*Currency)(nil) + _ scannerValuer = (*FileContractID)(nil) + _ scannerValuer = (*Hash256)(nil) + _ scannerValuer = (*Settings)(nil) + _ scannerValuer = (*PriceTable)(nil) + _ scannerValuer = (*PublicKey)(nil) + _ scannerValuer = (*SecretKey)(nil) + _ scannerValuer = (*UnixTimeMS)(nil) + _ scannerValuer = (*UnixTimeNS)(nil) + _ scannerValuer = (*Unsigned64)(nil) ) // Scan scan value into AutopilotConfig, implements sql.Scanner interface. @@ -208,6 +220,11 @@ func (k *SecretKey) Scan(value interface{}) error { return nil } +// Value returns an key value, implements driver.Valuer interface. +func (k SecretKey) Value() (driver.Value, error) { + return []byte(k), nil +} + // Scan scan value into unixTimeMS, implements sql.Scanner interface. func (u *UnixTimeMS) Scan(value interface{}) error { var msec int64