From 6a6c5bd70e858cc24207d0b336082a5a2b2a383f Mon Sep 17 00:00:00 2001 From: Vladimir Chalenko Date: Fri, 20 Nov 2020 08:44:31 +0300 Subject: [PATCH] fix json inserting issue to psql --- testfixtures.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testfixtures.go b/testfixtures.go index e80d2a8..f0162fb 100644 --- a/testfixtures.go +++ b/testfixtures.go @@ -3,6 +3,7 @@ package testfixtures // import "github.com/go-testfixtures/testfixtures/v3" import ( "bytes" "database/sql" + "encoding/json" "fmt" "io/ioutil" "os" @@ -501,7 +502,12 @@ func (l *Loader) buildInsertSQL(f *fixtureFile, record map[interface{}]interface value = t } case []interface{}, map[interface{}]interface{}: - value = recursiveToJSON(v) + var jsn []byte + jsn, err = json.Marshal(recursiveToJSON(v)) + if err != nil { + return + } + value = string(jsn) } switch l.helper.paramType() {