Skip to content

Commit

Permalink
Merge pull request #3 from ulule/fix/handle-json-arrays
Browse files Browse the repository at this point in the history
fix: handle json arrays
  • Loading branch information
thoas authored Jan 19, 2021
2 parents 1688ada + c78cf7b commit 8b02d77
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dialect/postgres/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ func valuesToPairs(table dialect.Table, data map[string]interface{}) ([]interfac
return nil, fmt.Errorf("unable to encode %v to pgtype.VarcharArray: %w", elements, err)
}
pairs[i] = lk.Pair(k, values)
case "jsonb":
b, err := json.Marshal(v)
if err != nil {
return nil, fmt.Errorf("unable to encode %v to JSON: %w", v, err)
}
pairs[i] = lk.Pair(k, &pgtype.JSONB{Bytes: b, Status: pgtype.Present})
default:
pairs[i] = lk.Pair(k, v)
}
Expand Down

0 comments on commit 8b02d77

Please sign in to comment.