ClickHouse / ClickHouse/clickhouse-js
Cannot read bytes from String or FixedString(N)
- Dominant language
- TypeScript
- Stars
- 331
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
### 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
1. Store raw hash or any other raw bytes in Clickhouse DB
2. Directly select it through clickhouse-js, formatting as any CSV or JSON
3. convert the string to bytes
```javascript
function stringToBytes(str) {
const bytes = [];
for (let i = 0; i < str.length; i++) {
const codeUnit = str.charCodeAt(i);
bytes.push(codeUnit);
}
return bytes;
}
```
4. 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](https://github.com/ClickHouse/ClickHouse/blob/master/programs/obfuscator/Obfuscator.cpp#L42-L80) if necessary
Contributor guide
Assessment
This issue has not been assessed yet.