Skip to content

Commit

Permalink
Make sure types implement Scanner and Valuer (#1319)
Browse files Browse the repository at this point in the history
Not really a fix but better safe than sorry
  • Loading branch information
ChrisSchinnerl authored Jun 18, 2024
1 parent bef6b56 commit 2378476
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions stores/sql/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2378476

Please sign in to comment.