Skip to content

Commit 5cb495f

Browse files
committed
Implement Int64Valuer for zeronull int types
1 parent 25cba15 commit 5cb495f

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
@@ -32,6 +32,14 @@ func (dst *Int<%= pg_byte_size %>) ScanInt64(n int64, valid bool) error {
3232
return nil
3333
}
3434

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

0 commit comments

Comments
 (0)