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>
Этот коммит содержится в:
Kyriakos Z
2022-01-26 11:36:33 +02:00
коммит произвёл GitHub
родитель 05dcd0217c
Коммит 513a4669cc

Просмотреть файл

@@ -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