Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 02ac2c0

Browse files
committed
common: Use correct text representation of BLOBs for internal use
When reading in the results of a query correctly convert the binary data of BLOBs to a text representation in the x'1234' format instead of just trying to treat it as a string.
1 parent 3aa9cdc commit 02ac2c0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

common/sqlite.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,13 @@ func SQLiteRunQuery(sdb *sqlite.Conn, querySource QuerySource, dbQuery string, i
768768
row = append(row, DataValue{Name: dataRows.ColNames[i], Type: Binary,
769769
Value: base64.StdEncoding.EncodeToString(b)})
770770
case Internal:
771+
stringVal := "x'"
772+
for _, c := range b {
773+
stringVal += fmt.Sprintf("%02x", c)
774+
}
775+
stringVal += "'"
771776
row = append(row, DataValue{Name: dataRows.ColNames[i], Type: Binary,
772-
Value: b})
777+
Value: stringVal})
773778
default:
774779
row = append(row, DataValue{Name: dataRows.ColNames[i], Type: Binary,
775780
Value: "<i>BINARY DATA</i>"})
@@ -957,8 +962,10 @@ func EscapeValue(val DataValue) string {
957962
return "NULL"
958963
} else if val.Type == Integer || val.Type == Float {
959964
return val.Value.(string)
960-
} else {
965+
} else if val.Type == Text {
961966
return sqlite.Mprintf("%Q", val.Value.(string))
967+
} else { // BLOB and similar
968+
return val.Value.(string)
962969
}
963970
}
964971

0 commit comments

Comments
 (0)