Skip to content

Unable to read values with NUL in them #158

Description

@corrideat

Using jsr:@db/[email protected], I'm unable to read values from the DB if they contain a NUL in them (the value is truncated)

import * as sqlite from 'jsr:@db/sqlite'

const db = new sqlite.Database('./example.db')
db.run('CREATE TABLE IF NOT EXISTS Data(key TEXT NOT NULL PRIMARY KEY, value TEXT NOT NULL)')
const readStatement = db.prepare('SELECT value FROM Data WHERE key = ?')
const writeStatement = db.prepare('REPLACE INTO Data(key, value) VALUES(?, ?)')

writeStatement.run('foo', 'bar\x00baz')
console.error(readStatement.get('foo'))
// Result is `{ value: "bar" }` but it should have been `{ value: "bar\x00baz" }`, or a buffer with "bar\x00baz"
// Opening the DB with SQLite shows the correct values

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions