add dat base

This commit is contained in:
2022-12-31 17:17:10 +01:00
parent 6fb82df153
commit 4ff22d7d63
27 changed files with 1337 additions and 36 deletions
@@ -0,0 +1,36 @@
package sqltypes
import (
"database/sql/driver"
"encoding/json"
"errors"
)
type NullRawMessage struct {
RawMessage json.RawMessage
Valid bool
}
func (n *NullRawMessage) Scan(value interface{}) error {
if value == nil {
n.RawMessage, n.Valid = json.RawMessage{}, false
return nil
}
buf, ok := value.([]byte)
if !ok {
return errors.New("cannot parse to bytes")
}
n.RawMessage, n.Valid = buf, true
return nil
}
func (n NullRawMessage) Value() (driver.Value, error) {
if !n.Valid {
return nil, nil
}
return []byte(n.RawMessage), nil
}