-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Currently, null values from the query results do not map and rather error out when trying to map to a struct's value type field. This however works if the target field is a pointer.
If the resulting value is null and the target is a value type field, resort to the default value
i.e., if the record 1, John, doe, john@doe.com, null is being mapped to the following struct
type struct User {
ID int64 `db:"id"`
FirstName string `db:"first_name"`
LastName string `db:"last_name"`
Email string `db:"email"`
Phone string `db:"string"`
}
Phone should be set to an empty string. Currently this errors out.
However, we must retain the functionality of the value being set to null if the target is a pointer
i.e.,
Phone *string `db:"string"`