Loggest thy stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

36 lines
567 B

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
}