-
Notifications
You must be signed in to change notification settings - Fork 848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add comment for pgtype.Interval struct #2113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
pgtype/interval.go
Outdated
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementing Scanner is not why it can be used as a destination in pgx. That's only when used through database/sql.
pgtype/interval.go
Outdated
// // NULL value | ||
// } | ||
// | ||
// When using as a parameter for prepared statement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether or not a prepared statement is used makes no difference.
pgtype/interval.go
Outdated
// } | ||
// | ||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.