diff --git a/pgtype/interval.go b/pgtype/interval.go index 4b5116295..228f77e01 100644 --- a/pgtype/interval.go +++ b/pgtype/interval.go @@ -26,6 +26,21 @@ type IntervalValuer interface { IntervalValue() (Interval, error) } +// Interval represents an interval that may be null. +// Interval implements the [Scanner] interface so +// it can be used as a scan destination: +// +// var i Interval +// err := conn.QueryRow(context.Background(), "SELECT elapsed_time FROM foo WHERE id=$1", id).Scan(&i) +// ... +// if i.Valid { +// // use i.Days... +// } else { +// // NULL value +// } +// +// When using as a parameter for prepared statement +// the [Valid] field has to be explicitly set to [true] by the user. type Interval struct { Microseconds int64 Days int32