Skip to content

Commit a9c30da

Browse files
committed
sqldb: add helper for type boolean
1 parent 2d03204 commit a9c30da

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sqldb/sqlutils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ func SQLStrValid(s string) sql.NullString {
7575
}
7676
}
7777

78+
// SQLBool turns a boolean into the NullBool that sql/sqlc uses when a boolean
79+
// can be permitted to be NULL.
80+
func SQLBool(b bool) sql.NullBool {
81+
return sql.NullBool{
82+
Bool: b,
83+
Valid: true,
84+
}
85+
}
86+
7887
// SQLTime turns a time.Time into the NullTime that sql/sqlc uses when a time
7988
// can be permitted to be NULL.
8089
func SQLTime(t time.Time) sql.NullTime {

0 commit comments

Comments
 (0)