clickhouse-js
clickhouse-js copied to clipboard
Cannot read bytes from String or FixedString(N)
Describe the bug
Directly select a String or FixedString(N) column which stores raw bytes rather than UTF-8 string, the result will contain
e.g.
the correct value of this should be the hash unhex('000000708550f340a1297eefe721a3b0631d8dc4cc5a3462abaeef1a79726f6b')
Steps to reproduce
- Store raw hash or any other raw bytes in Clickhouse DB
- Directly select it through clickhouse-js, formatting as any CSV or JSON
- convert the string to bytes
function stringToBytes(str) {
const bytes = [];
for (let i = 0; i < str.length; i++) {
const codeUnit = str.charCodeAt(i);
bytes.push(codeUnit);
}
return bytes;
}
- the value is incorrect and ruined by
65533
Expected behaviour
return a correct string or bytes
Code example
as shown in Steps to reproduce
Error log
Configuration
Environment
- Client version: latest, 1.1.0
- Language version:
- OS: Chrome
ClickHouse server
- ClickHouse Server version: clickhouse/clickhouse-server:23.12.4-alpine
- ClickHouse Server non-default settings, if any:
-
CREATE TABLE
statements for tables involved: - Sample data for all these tables, use clickhouse-obfuscator if necessary