sqldb: add SQLInt16 helper
This commit is contained in:
1 file changed
+12
@@ -11,6 +11,18 @@ import (
|
||||
// reset function ExecTx calls.
|
||||
var NoOpReset = func() {}
|
||||
|
||||
// SQLInt16 turns a numerical integer type into the NullInt16 that sql/sqlc
|
||||
// uses when an integer field can be permitted to be NULL.
|
||||
//
|
||||
// We use this constraints.Integer constraint here which maps to all signed and
|
||||
// unsigned integer types.
|
||||
func SQLInt16[T constraints.Integer](num T) sql.NullInt16 {
|
||||
return sql.NullInt16{
|
||||
Int16: int16(num),
|
||||
Valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
// SQLInt32 turns a numerical integer type into the NullInt32 that sql/sqlc
|
||||
// uses when an integer field can be permitted to be NULL.
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user