• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 17543477247

08 Sep 2025 07:40AM UTC coverage: 66.634%. Remained the same
17543477247

push

github

web-flow
Merge pull request #10196 from ziggie1984/refactor-payment-part-6

refactor payments part 6

62 of 87 new or added lines in 5 files covered. (71.26%)

61 existing lines in 19 files now uncovered.

136141 of 204312 relevant lines covered (66.63%)

21446.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.25
/sqldb/sqlutils.go
1
package sqldb
2

3
import (
4
        "database/sql"
5
        "time"
6

7
        "golang.org/x/exp/constraints"
8
)
9

10
// NoOpReset is a no-op function that can be used as a default
11
// reset function ExecTx calls.
12
var NoOpReset = func() {}
22,435✔
13

14
// SQLInt16 turns a numerical integer type into the NullInt16 that sql/sqlc
15
// uses when an integer field can be permitted to be NULL.
16
//
17
// We use this constraints.Integer constraint here which maps to all signed and
18
// unsigned integer types.
19
func SQLInt16[T constraints.Integer](num T) sql.NullInt16 {
×
20
        return sql.NullInt16{
×
21
                Int16: int16(num),
×
22
                Valid: true,
×
23
        }
×
24
}
×
25

26
// SQLInt32 turns a numerical integer type into the NullInt32 that sql/sqlc
27
// uses when an integer field can be permitted to be NULL.
28
//
29
// We use this constraints.Integer constraint here which maps to all signed and
30
// unsigned integer types.
31
func SQLInt32[T constraints.Integer](num T) sql.NullInt32 {
20,592✔
32
        return sql.NullInt32{
20,592✔
33
                Int32: int32(num),
20,592✔
34
                Valid: true,
20,592✔
35
        }
20,592✔
36
}
20,592✔
37

38
// SQLInt64 turns a numerical integer type into the NullInt64 that sql/sqlc
39
// uses when an integer field can be permitted to be NULL.
40
//
41
// We use this constraints.Integer constraint here which maps to all signed and
42
// unsigned integer types.
43
func SQLInt64[T constraints.Integer](num T) sql.NullInt64 {
31,256✔
44
        return sql.NullInt64{
31,256✔
45
                Int64: int64(num),
31,256✔
46
                Valid: true,
31,256✔
47
        }
31,256✔
48
}
31,256✔
49

50
// SQLStr turns a string into the NullString that sql/sqlc uses when a string
51
// can be permitted to be NULL.
52
//
53
// NOTE: If the input string is empty, it returns a NullString with Valid set to
54
// false. If this is not the desired behavior, consider using SQLStrValid
55
// instead.
56
func SQLStr(s string) sql.NullString {
20,592✔
57
        if s == "" {
20,990✔
58
                return sql.NullString{}
398✔
59
        }
398✔
60

61
        return sql.NullString{
20,194✔
62
                String: s,
20,194✔
63
                Valid:  true,
20,194✔
64
        }
20,194✔
65
}
66

67
// SQLStrValid turns a string into the NullString that sql/sqlc uses when a
68
// string can be permitted to be NULL.
69
//
70
// NOTE: Valid is always set to true, even if the input string is empty.
71
func SQLStrValid(s string) sql.NullString {
×
72
        return sql.NullString{
×
73
                String: s,
×
74
                Valid:  true,
×
75
        }
×
76
}
×
77

78
// SQLBool turns a boolean into the NullBool that sql/sqlc uses when a boolean
79
// can be permitted to be NULL.
NEW
80
func SQLBool(b bool) sql.NullBool {
×
NEW
81
        return sql.NullBool{
×
NEW
82
                Bool:  b,
×
NEW
83
                Valid: true,
×
NEW
84
        }
×
NEW
85
}
×
86

87
// SQLTime turns a time.Time into the NullTime that sql/sqlc uses when a time
88
// can be permitted to be NULL.
89
func SQLTime(t time.Time) sql.NullTime {
64,988✔
90
        return sql.NullTime{
64,988✔
91
                Time:  t,
64,988✔
92
                Valid: true,
64,988✔
93
        }
64,988✔
94
}
64,988✔
95

96
// ExtractSqlInt16 turns a NullInt16 into a numerical type. This can be useful
97
// when reading directly from the database, as this function handles extracting
98
// the inner value from the "option"-like struct.
99
func ExtractSqlInt16[T constraints.Integer](num sql.NullInt16) T {
×
100
        return T(num.Int16)
×
101
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc