Add comment for pgtype.Interval struct#2113
Conversation
jackc
left a comment
There was a problem hiding this comment.
Sorry, but there are several errors in the comments.
But beyond that, I really don't think that this is the place to explain Valid. Otherwise, we would need more or less duplicate comments on all the types. A package level comment on the pgtype package would be more reasonable.
|
|
||
| // Interval represents an interval that may be null. | ||
| // Interval implements the [Scanner] interface so | ||
| // it can be used as a scan destination: |
There was a problem hiding this comment.
Implementing Scanner is not why it can be used as a destination in pgx. That's only when used through database/sql.
| // // NULL value | ||
| // } | ||
| // | ||
| // When using as a parameter for prepared statement |
There was a problem hiding this comment.
Whether or not a prepared statement is used makes no difference.
| // } | ||
| // | ||
| // When using as a parameter for prepared statement | ||
| // the [Valid] field has to be explicitly set to [true] by the user. |
There was a problem hiding this comment.
Valid has to be set if it is not NULL. It is perfectly reasonable for Valid to be false when representing a NULL.
Additional information warns about using nullable types being used as parameters to query with Valid set to false.
|
Many thanks for your comments. Made me have a deeper look into pgtype. I added a short notice to the Anyhow, wanted to thank you for your awesome work! |
Comment explicitly states that pgtype.Interval is a nullable postgres type.