Skip to content

Commit 6bcbbaa

Browse files
committed
tapdb: add new extractBool helper function
In this commit, we add a new `extractBool` helper function. In an upcoming commit, we'll use this to fix incorrect usage of the `sql.NullBool` type.
1 parent 8e070bd commit 6bcbbaa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tapdb/sqlutils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ func extractSqlInt16[T constraints.Integer](num sql.NullInt16) T {
103103
return T(num.Int16)
104104
}
105105

106+
// extractBool turns a NullBool into a boolean. This can be useful when reading
107+
// directly from the database, as this function handles extracting the inner
108+
// value from the "option"-like struct.
109+
func extractBool(b sql.NullBool) bool {
110+
return b.Bool
111+
}
112+
106113
// readOutPoint reads the next sequence of bytes from r as an OutPoint.
107114
//
108115
// NOTE: This function is intended to be used along with the wire.WriteOutPoint

0 commit comments

Comments
 (0)