Skip to content

Commit 594d9d6

Browse files
authored
Merge pull request #2367 from zeghong/zeronull-int-scanner
Ensure zeronull int types implement Int64Scanner
2 parents cc34da5 + 5a18241 commit 594d9d6

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

pgtype/zeronull/int.go

Lines changed: 21 additions & 21 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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ type Int<%= pg_byte_size %> int<%= pg_bit_size %>
1616
func (Int<%= pg_byte_size %>) SkipUnderlyingTypePlan() {}
1717

1818
// ScanInt64 implements the [pgtype.Int64Scanner] interface.
19-
func (dst *Int<%= pg_byte_size %>) ScanInt64(n int64, valid bool) error {
20-
if !valid {
19+
func (dst *Int<%= pg_byte_size %>) ScanInt64(n pgtype.Int8) error {
20+
if !n.Valid {
2121
*dst = 0
2222
return nil
2323
}
2424

25-
if n < math.MinInt<%= pg_bit_size %> {
26-
return fmt.Errorf("%d is greater than maximum value for Int<%= pg_byte_size %>", n)
25+
if n.Int64 < math.MinInt<%= pg_bit_size %> {
26+
return fmt.Errorf("%d is less than minimum value for Int<%= pg_byte_size %>", n.Int64)
2727
}
28-
if n > math.MaxInt<%= pg_bit_size %> {
29-
return fmt.Errorf("%d is greater than maximum value for Int<%= pg_byte_size %>", n)
28+
if n.Int64 > math.MaxInt<%= pg_bit_size %> {
29+
return fmt.Errorf("%d is greater than maximum value for Int<%= pg_byte_size %>", n.Int64)
3030
}
31-
*dst = Int<%= pg_byte_size %>(n)
31+
*dst = Int<%= pg_byte_size %>(n.Int64)
3232

3333
return nil
3434
}

0 commit comments

Comments
 (0)