chore: ⬆️ Vendor for new deps
This commit is contained in:
73
vendor/github.com/microsoft/go-mssqldb/uniqueidentifier_null.go
generated
vendored
Normal file
73
vendor/github.com/microsoft/go-mssqldb/uniqueidentifier_null.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
package mssql
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type NullUniqueIdentifier struct {
|
||||
UUID UniqueIdentifier
|
||||
Valid bool // Valid is true if UUID is not NULL
|
||||
}
|
||||
|
||||
func (n *NullUniqueIdentifier) Scan(v interface{}) error {
|
||||
if v == nil {
|
||||
*n = NullUniqueIdentifier{
|
||||
UUID: [16]byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
|
||||
Valid: false,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
u := n.UUID
|
||||
err := u.Scan(v)
|
||||
*n = NullUniqueIdentifier{
|
||||
UUID: u,
|
||||
Valid: true,
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (n NullUniqueIdentifier) Value() (driver.Value, error) {
|
||||
if !n.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return n.UUID.Value()
|
||||
}
|
||||
|
||||
func (n NullUniqueIdentifier) String() string {
|
||||
if !n.Valid {
|
||||
return "NULL"
|
||||
}
|
||||
return n.UUID.String()
|
||||
}
|
||||
|
||||
func (n NullUniqueIdentifier) MarshalText() (text []byte, err error) {
|
||||
if !n.Valid {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
return n.UUID.MarshalText()
|
||||
}
|
||||
|
||||
func (n *NullUniqueIdentifier) UnmarshalJSON(b []byte) error {
|
||||
u := n.UUID
|
||||
if string(b) == "null" {
|
||||
*n = NullUniqueIdentifier{
|
||||
UUID: [16]byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
|
||||
Valid: false,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
err := u.UnmarshalJSON(b)
|
||||
*n = NullUniqueIdentifier{
|
||||
UUID: u,
|
||||
Valid: true,
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (n NullUniqueIdentifier) MarshalJSON() ([]byte, error) {
|
||||
if !n.Valid {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
return json.Marshal(n.UUID)
|
||||
}
|
||||
Reference in New Issue
Block a user