Skip to content

Commit a295d68

Browse files
authored
Merge pull request #2368 from zeghong/zeronull-int-valuer
Implement Int64Valuer for zeronull int types
2 parents 82fbe49 + 03f32c0 commit a295d68

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

‎pgtype/zeronull/int.go‎

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pgtype/zeronull/int.go.erb‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ func (dst *Int<%= pg_byte_size %>) ScanInt64(n pgtype.Int8) error {
3333
return nil
3434
}
3535

36+
// Int64Value implements the [pgtype.Int64Valuer] interface.
37+
func (src Int<%= pg_byte_size %>) Int64Value() (pgtype.Int8, error) {
38+
if src == 0 {
39+
return pgtype.Int8{}, nil
40+
}
41+
return pgtype.Int8{Int64: int64(src), Valid: true}, nil
42+
}
43+
3644
// Scan implements the [database/sql.Scanner] interface.
3745
func (dst *Int<%= pg_byte_size %>) Scan(src any) error {
3846
if src == nil {

0 commit comments

Comments
 (0)