Skip to content

Commit 3729070

Browse files
committed
feat: add NewNull
1 parent 92c1b2c commit 3729070

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

null.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func (n Null[T]) Value() (driver.Value, error) {
9292
return n.V, nil
9393
}
9494

95+
// NewNull returns a new, non-null Null.
96+
func NewNull[T any](v T) Null[T] {
97+
return Null[T]{V: v, Valid: true}
98+
}
99+
95100
var errNilPtr = errors.New("destination pointer is nil") // embedded in descriptive error
96101

97102
// convertAssign is the same as convertAssignRows, but without the optional

0 commit comments

Comments
 (0)