From 5316eaa975d589f616fb0b5fabc5703356ca5e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Tikvi=C4=87?= Date: Fri, 26 May 2017 11:20:07 +0200 Subject: [PATCH] ora v4 bug with utf-8 clob --- json_utility.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/json_utility.go b/json_utility.go index d29894f..ad486d7 100644 --- a/json_utility.go +++ b/json_utility.go @@ -1,6 +1,7 @@ package webutility import ( + "fmt" "net/http" "encoding/json" "errors" @@ -149,7 +150,7 @@ func InitTables(db *ora.Ses, project string) error { mu.Lock() defer mu.Unlock() - json.Unmarshal([]byte(jsonbuf), &payloads) + json.Unmarshal(jsonbuf, &payloads) if len(payloads) == 0 { return errors.New("tables config is corrupt") } @@ -158,16 +159,16 @@ func InitTables(db *ora.Ses, project string) error { // fetchJSON returns a byte slice of JSON configuration file from TABLES_CONFIG table. // Returns an error if it fails. -func fetchJSON(db *ora.Ses, project string) (string, error) { +func fetchJSON(db *ora.Ses, project string) ([]byte, error) { stmt, err := db.Prep(`SELECT JSON_CLOB FROM TABLES_CONFIG WHERE PROJEKAT` + EqualQuotes(project), ora.S) defer stmt.Close() if err != nil { - return "", err + return nil, err } rset, err := stmt.Qry() if err != nil { - return "", err + return nil, err } var data string @@ -175,7 +176,8 @@ func fetchJSON(db *ora.Ses, project string) (string, error) { data = rset.Row[0].(string) } - return data, nil + fmt.Println(data) + return []byte(data), nil } // DecodeJSON decodes JSON data from r to v. -- 1.8.1.2