From b4e1de020d27541e47eeeaa069e097fa04fc2eb0 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sat, 26 Oct 2024 09:19:54 +0300 Subject: [PATCH] chore: add a comment --- model_map.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/model_map.go b/model_map.go index 99a5192a3..d7342576f 100644 --- a/model_map.go +++ b/model_map.go @@ -1,6 +1,7 @@ package bun import ( + "bytes" "context" "database/sql" "reflect" @@ -82,11 +83,9 @@ func (m *mapModel) Scan(src interface{}) error { return m.scanRaw(src) case reflect.Slice: if scanType.Elem().Kind() == reflect.Uint8 { - srcB := src.([]byte) - src2 := make([]byte, len(srcB)) - copy(src2, srcB) - - return m.scanRaw(src2) + // Reference types such as []byte are only valid until the next call to Scan. + src := bytes.Clone(src.([]byte)) + return m.scanRaw(src) } }