Open
Description
Go version
go 1.22.4
GoFrame version
gf 2.9.0
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
The image data contains 0x5D with bytea type.
What did you see happen?
It will be forcibly converted to 0x7D.
What did you expect to see?
This causes image parsing to fail by the function in the file contrib/drivers/pgsql/pgsql_convert.go.
func (d *Driver) ConvertValueForField(ctx context.Context, fieldType string, fieldValue interface{}) (interface{}, error) {
if g.IsNil(fieldValue) {
return d.Core.ConvertValueForField(ctx, fieldType, fieldValue)
}
var fieldValueKind = reflect.TypeOf(fieldValue).Kind()
if fieldValueKind == reflect.Slice {
// For pgsql, json or jsonb require '[]'
if !gstr.Contains(fieldType, "json") {
if fileBytes, ok := fieldValue.([]byte); ok && fieldType == "bytea" {
fieldValue = fileBytes
} else {
fieldValue = gstr.ReplaceByMap(gconv.String(fieldValue),
map[string]string{
"[": "{",
"]": "}",
},
)
}
}
}
return d.Core.ConvertValueForField(ctx, fieldType, fieldValue)
}