Add pgduration
This commit is contained in:
1 parent
36416ee551
commit
8c833e06cd
4 files changed
+109
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package pgduration
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
)
|
||||
|
||||
type NullDuration struct {
|
||||
Duration Duration
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func (d NullDuration) Value() (driver.Value, error) {
|
||||
return d.Duration.Value()
|
||||
}
|
||||
|
||||
func (d *NullDuration) Scan(src any) error {
|
||||
switch src.(type) {
|
||||
case nil:
|
||||
d.Valid = false
|
||||
default:
|
||||
var err = d.Duration.Scan(src)
|
||||
d.Valid = err == nil
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user