-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed as not planned
Labels
Description
GORM Playground Link
Description
I find out that GORM cast byte arrays to strings, if ColumnTypeScanType
returns sql.RawBytes.
Line 44 in 0daaf17
} else if b, ok := mapValue[column].(sql.RawBytes); ok { |
This behaviour was introduced in 2020 and actually it's not clear why it do so.
I thing it's logical that if db value is sql.RawBytes, then it should return []byte
, not string, because you can have arbitrary byte array there that during scanning should not change to other type.
go-sqlite return sql.RawBytes
as type for BLOB which is https://www.sqlite.org/datatype3.html – The value is a blob of data, stored exactly as it was input.
But together with GORM if dest is map[string]interface{}
we get string instead