Add SqlNullString PB helper

This commit is contained in:
Mustafa Gezen 2023-08-25 18:44:24 +02:00
parent 082ebd4994
commit fbf14f6c11

View File

@ -17,6 +17,7 @@ package base
import (
"database/sql"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)
func SqlNullTime(t sql.NullTime) *timestamppb.Timestamp {
@ -25,3 +26,10 @@ func SqlNullTime(t sql.NullTime) *timestamppb.Timestamp {
}
return timestamppb.New(t.Time)
}
func SqlNullString(s sql.NullString) *wrapperspb.StringValue {
if !s.Valid {
return nil
}
return wrapperspb.String(s.String)
}