Skip to content

Commit

Permalink
fix: JSON as string
Browse files Browse the repository at this point in the history
  • Loading branch information
23doors committed Aug 13, 2020
1 parent 91b7989 commit ff68e9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion database/fields/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ func (j JSON) Value() (driver.Value, error) {
return string(b), e
}

return j.JSON.Value()
v, e := j.JSON.Value()
if e != nil {
return v, e
}

return string(v.([]byte)), e
}

func (j *JSON) Get() interface{} {
Expand Down
7 changes: 6 additions & 1 deletion database/fields/jsonb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ func (j JSONB) Value() (driver.Value, error) {
return string(b), e
}

return j.JSONB.Value()
v, e := j.JSONB.Value()
if e != nil {
return v, e
}

return string(v.([]byte)), e
}

func (j *JSONB) Get() interface{} {
Expand Down

0 comments on commit ff68e9e

Please sign in to comment.