Handle null strings in I18nInput.FillArray

Until now i always had the translations be empty strings if some columns
did not have the full translation, but this is going too far on the
non-NULL policy: surely they have a translations, but we do not know it
yet; this is the exact type of situations NULL values are for.

Besides the philosophical distinction, having empty strings instead of
NULLs is less practical, because i no longer can user coalesce() to
retrieve the default language text in case the translation for that
particular field is not available, even if the row for a locale exists.

In time i will change all _i18n relations, but for now only these from
campsite follow the “new policy”.
This commit is contained in:
jordi fita mas 2024-01-26 22:31:11 +01:00
parent c284230436
commit bd124581cc
1 changed files with 6 additions and 1 deletions

View File

@ -70,7 +70,12 @@ func (input I18nInput) FillArray(array database.RecordArray) error {
if err != nil {
return err
}
input[tag.String()].Val = el.Fields[1].Get().(string)
val := el.Fields[1].Get()
if val == nil {
input[tag.String()].Val = ""
} else {
input[tag.String()].Val = val.(string)
}
}
return nil
}