From 4ac0a09b850cb60ca89ec14cc66aad1cf4de6e91 Mon Sep 17 00:00:00 2001 From: Levente Batuska Date: Sat, 4 Jan 2025 02:41:56 +0100 Subject: [PATCH] fix(Type): promote case driver.Valuer to the top in switch statement for Optional Value --- type/optional.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/type/optional.go b/type/optional.go index c1aef5a..bc7ce0c 100644 --- a/type/optional.go +++ b/type/optional.go @@ -295,6 +295,9 @@ func (o Optional[T]) Value() (driver.Value, error) { switch v := any(o.Value).(type) { + case driver.Valuer: + return v.Value() + case string, bool, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr, @@ -311,8 +314,6 @@ func (o Optional[T]) Value() (driver.Value, error) { case fmt.Stringer: return v.String(), nil - case driver.Valuer: - return v.Value() default: return nil, errors.New("unsupported type for Optional")