Update type for blob to be byte array, instead of sql.RawBytes #1274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After this PR was merged https://github.com/mattn/go-sqlite3/pull/909/files go-sqlite started return correct types for sqlite types.
However the change of type for BLOB ends up to the fact, that in GORM deserialization of byte arrays become string. The reason of this is because GORM cast all
sql.RawBytes
to strings for some reasons here https://github.com/go-gorm/gorm/blob/0daaf1747cfa4e4850376ad50a7834fb78b0cc0e/scan.go#L44My assumption is that GORM do so, as a lot of drivers for different DBs return some good values for this sql.RawBytes. (here is example of issues raised go-gorm/gorm#5783)
I asked question in GORM repo about this go-gorm/gorm#7189, but some solution that can be is to change
sql.RawBytes
toreflect.SliceOf(reflect.TypeOf(byte(0)))
(as it was before) to return BLOB as byte arrays there. This then should not introduce breaking changes nor in GORM nor in go-sqlite