From 88da5816c3f32e38c04ff60852d14066bef26425 Mon Sep 17 00:00:00 2001 From: oddyamill <43600905+oddyamill@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:08:47 +0700 Subject: [PATCH] fix(crypto): sql char support --- internal/crypto/crypto.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/crypto/crypto.go b/internal/crypto/crypto.go index a3c1969..885f62c 100644 --- a/internal/crypto/crypto.go +++ b/internal/crypto/crypto.go @@ -76,12 +76,16 @@ func (c *Crypt) Decrypt() string { } func (c *Crypt) Scan(src any) error { - text, ok := src.(string) - - if !ok { - return nil + switch value := src.(type) { + case string: + c.Encrypted = value + case []byte: + c.Encrypted = helpers.BytesToString(value) + case nil: + c.Encrypted = "" + default: + return errors.New("unsupported type") } - c.Encrypted = text return nil }