3
0

Fix boolean field Backward compatibility for alias store codec

The JSON record value codec properly encoded T/F as "1"/"" but
the plain codec did not.
This commit is contained in:
Tomaž Jerman
2022-07-18 18:40:34 +02:00
parent aaa536441b
commit c8179f74d4

View File

@@ -70,6 +70,19 @@ func (c *SingleValueColumn) Decode(raw any, r dal.ValueSetter) error {
return err
}
// now, encode the value according to JSON format constraints
switch c.attr.Type.(type) {
case *dal.TypeBoolean:
// for backward compatibility reasons
// we need to cast true bool values to "1"
// and use "" for other (false) values
if cast.ToBool(value) {
value = "1"
} else {
value = ""
}
}
ident := c.attr.Ident
if !valid {
return r.SetValue(ident, 0, nil)