DriverValue implements the [DriverValuer] interface.
(record *Record)
| 168 | |
| 169 | // DriverValue implements the [DriverValuer] interface. |
| 170 | func (f *SelectField) DriverValue(record *Record) (driver.Value, error) { |
| 171 | val := list.ToUniqueStringSlice(record.GetRaw(f.Name)) |
| 172 | |
| 173 | if !f.IsMultiple() { |
| 174 | if len(val) > 0 { |
| 175 | return val[len(val)-1], nil // the last selected |
| 176 | } |
| 177 | return "", nil |
| 178 | } |
| 179 | |
| 180 | // serialize as json string array |
| 181 | return append(types.JSONArray[string]{}, val...), nil |
| 182 | } |
| 183 | |
| 184 | // ValidateValue implements [Field.ValidateValue] interface method. |
| 185 | func (f *SelectField) ValidateValue(ctx context.Context, app App, record *Record) error { |
nothing calls this directly
no test coverage detected