MM-41066: fixes replies when binary_parameters=yes (#19404)
* MM-41066: fixes replies when binary_parameters=yes
Migrating post_store from gorp to sqlx breaks replies on threads.
Why? Participants is a jsonb field and when binary_parameters is set to
'yes' it is failing to insert because it needs the version (1) to be
prepended to the bytes array ([]byte{0x01}).
The easiest fix on this is to cast to a string when inserting.
There is a drawback though, non utf8 characters would be replaced by the
question mark icon �.
This commit does exactly that, casts StringArray to a string.
* Adds a comment
* Removes unnecessary conversion
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
@@ -76,7 +76,12 @@ func (sa StringArray) Equals(input StringArray) bool {
|
||||
|
||||
// Value converts StringArray to database value
|
||||
func (sa StringArray) Value() (driver.Value, error) {
|
||||
return json.Marshal(sa)
|
||||
j, err := json.Marshal(sa)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// non utf8 characters are not supported
|
||||
return string(j), err
|
||||
}
|
||||
|
||||
// Scan converts database column value to StringArray
|
||||
|
||||
Ссылка в новой задаче
Block a user