Skip to content

Commit

Permalink
entgql: fixed pulid example
Browse files Browse the repository at this point in the history
Signed-off-by: Giau. Tran Minh <hello@giautm.dev>
  • Loading branch information
giautm committed Feb 15, 2023
1 parent e104430 commit 6fa0371
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions entgql/internal/todopulid/ent/schema/pulid/pulid.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ func (u *ID) Scan(src interface{}) error {
if src == nil {
return fmt.Errorf("pulid: expected a value")
}
s, ok := src.(string)
if !ok {
return fmt.Errorf("pulid: expected a string")
switch src := src.(type) {
case string:
*u = ID(src)
case ID:
*u = src
default:
return fmt.Errorf("pulid: unexpected type, %T", src)
}
*u = ID(s)
return nil
}

Expand Down

0 comments on commit 6fa0371

Please sign in to comment.