Skip to content

Cannot read bytes from String or FixedString(N) #282

Open
@c0mm4nd

Description

@c0mm4nd

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.
image

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
                                    function stringToBytes(str) {
                                      const bytes = [];
                                      for (let i = 0; i < str.length; i++) {
                                        const codeUnit = str.charCodeAt(i);
                                        bytes.push(codeUnit);
                                      }
                                      return bytes;
                                    }
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions