Commit 5316eaa975d589f616fb0b5fabc5703356ca5e6f

Authored by Marko Tikvić
1 parent ec400817db
Exists in master and in 1 other branch v2

ora v4 bug with utf-8 clob

Showing 1 changed file with 7 additions and 5 deletions   Show diff stats
1 1 package webutility
2 2  
3 3 import (
  4 + "fmt"
4 5 "net/http"
5 6 "encoding/json"
6 7 "errors"
... ... @@ -149,7 +150,7 @@ func InitTables(db *ora.Ses, project string) error {
149 150  
150 151 mu.Lock()
151 152 defer mu.Unlock()
152   - json.Unmarshal([]byte(jsonbuf), &payloads)
  153 + json.Unmarshal(jsonbuf, &payloads)
153 154 if len(payloads) == 0 {
154 155 return errors.New("tables config is corrupt")
155 156 }
... ... @@ -158,16 +159,16 @@ func InitTables(db *ora.Ses, project string) error {
158 159  
159 160 // fetchJSON returns a byte slice of JSON configuration file from TABLES_CONFIG table.
160 161 // Returns an error if it fails.
161   -func fetchJSON(db *ora.Ses, project string) (string, error) {
  162 +func fetchJSON(db *ora.Ses, project string) ([]byte, error) {
162 163 stmt, err := db.Prep(`SELECT JSON_CLOB FROM TABLES_CONFIG WHERE PROJEKAT` + EqualQuotes(project), ora.S)
163 164 defer stmt.Close()
164 165 if err != nil {
165   - return "", err
  166 + return nil, err
166 167 }
167 168  
168 169 rset, err := stmt.Qry()
169 170 if err != nil {
170   - return "", err
  171 + return nil, err
171 172 }
172 173  
173 174 var data string
... ... @@ -175,7 +176,8 @@ func fetchJSON(db *ora.Ses, project string) (string, error) {
175 176 data = rset.Row[0].(string)
176 177 }
177 178  
178   - return data, nil
  179 + fmt.Println(data)
  180 + return []byte(data), nil
179 181 }
180 182  
181 183 // DecodeJSON decodes JSON data from r to v.
... ...