Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
Revert "go testfixtures: test non-native SQL type in sqlgen/livesql"
Browse files Browse the repository at this point in the history
This reverts commit 221d180.
  • Loading branch information
changpingc committed Sep 12, 2018
1 parent d105338 commit 3341c4c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions internal/testfixtures/custom_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,25 @@ import (
"fmt"
)

type CustomType [16]byte
type CustomType []byte

func CustomTypeFromString(s string) CustomType {
b := []byte(s)
c := CustomType{}
copy(c[:], b)
return c
return CustomType(s)
}

func (u CustomType) Value() (driver.Value, error) {
return []byte(u[:]), nil
return []byte(u), nil
}

func (u *CustomType) Scan(value interface{}) error {
switch value := value.(type) {
case nil:
u = nil
case string:
b := []byte(value)
copy(u[:], b)
case []byte:
copy(u[:], value)
*u = make(CustomType, len(value))
copy(*u, value)
case string:
*u = CustomType(value)
default:
return fmt.Errorf("cannot convert %v (of type %T) to %T", value, value, u)
}
Expand Down

0 comments on commit 3341c4c

Please sign in to comment.