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

lightningnetwork / lnd / 17236841262

26 Aug 2025 11:33AM UTC coverage: 66.228% (+8.9%) from 57.321%
17236841262

Pull #9147

github

web-flow
Merge 39fde1801 into 0c2f045f5
Pull Request #9147: [Part 1|3] Introduce SQL Payment schema into LND

129 of 1847 new or added lines in 13 files covered. (6.98%)

20 existing lines in 7 files now uncovered.

136069 of 205456 relevant lines covered (66.23%)

21357.68 hits per line

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

64.29
/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 {
32,138✔
44
        return sql.NullInt64{
32,138✔
45
                Int64: int64(num),
32,138✔
46
                Valid: true,
32,138✔
47
        }
32,138✔
48
}
32,138✔
49

50
// SQLStr turns a string into the NullString that sql/sqlc uses when a string
51
// can be permitted to be NULL.
52
func SQLStr(s string) sql.NullString {
20,592✔
53
        if s == "" {
20,987✔
54
                return sql.NullString{}
395✔
55
        }
395✔
56

57
        return sql.NullString{
20,197✔
58
                String: s,
20,197✔
59
                Valid:  true,
20,197✔
60
        }
20,197✔
61
}
62

63
// SQLBool turns a boolean into the NullBool that sql/sqlc uses when a boolean
64
// can be permitted to be NULL.
NEW
65
func SQLBool(b bool) sql.NullBool {
×
NEW
66
        return sql.NullBool{
×
NEW
67
                Bool:  b,
×
NEW
68
                Valid: true,
×
NEW
69
        }
×
NEW
70
}
×
71

72
// SQLTime turns a time.Time into the NullTime that sql/sqlc uses when a time
73
// can be permitted to be NULL.
74
func SQLTime(t time.Time) sql.NullTime {
68,405✔
75
        return sql.NullTime{
68,405✔
76
                Time:  t,
68,405✔
77
                Valid: true,
68,405✔
78
        }
68,405✔
79
}
68,405✔
80

81
// ExtractSqlInt16 turns a NullInt16 into a numerical type. This can be useful
82
// when reading directly from the database, as this function handles extracting
83
// the inner value from the "option"-like struct.
84
func ExtractSqlInt16[T constraints.Integer](num sql.NullInt16) T {
×
85
        return T(num.Int16)
×
86
}
×
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

© 2025 Coveralls, Inc