45
// Returns the zero value for the provided type and an appropriate error if the field is not found in
46
// the row or if the value cannot be cast to the provided type.
47
>
func getTypedFieldFromRow[T any](fieldName string, row map[string]any) (T, error) {
common.go
48
>
var zeroVal T // used as a placeholder for zero value of type T since we can't directly return nil
49
>
50
>
raw, ok := row[fieldName]
51
>
if !ok {
52
return zeroVal, newFieldNotFoundError(fieldName, row)
53
}
54
56
>
if !ok {
57
return zeroVal, newPersistedTypeMismatchError(fieldName, typed, raw, row)
58
}
59
61
}