libsql / libsql/knex-libsql

knex-libsql inserting wrong binary values on remote connection

Open
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11
Forks
0
PR merge metrics
No merged PRs in 30d

Description

I tried to insert some binary data with Buffer objects, and when I fetched the data, it gave me the wrong result like:

[ { id: 'ޭ��' } ]

To replicate:

await knex.schema.createTable("binary_data", (table) => {
  table.binary("id", 4)
})
await knex.table('binary_data').insert({ id: Buffer.from([0xde, 0xad, 0xbe, 0xef]) })
console.log(await this.knex.select().from('binary_data')) // output: [{ id: 'ޭ��' }]

I can replicate this when I connect to a remote database. Memory or file database works fine.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided reproduction against a remote database and compare its binary result with the memory and file database cases. Trace the remote connection's handling of the Buffer value and verify that selecting the inserted four-byte value returns the original binary data rather than a corrupted string.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, sqlite
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.