drizzle-team / drizzle-team/drizzle-orm

[BUG] SQLite Big integer stored as blob is unqueriable

Open
#2,902 0 comments 0 reactions 0 assignees View on GitHub
bug db/sqlite qb/crud
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.33.0

### What version of `drizzle-kit` are you using?

0.24.2

### Describe the Bug

1. Define a table with a primary key as a blob big int (as the example in the docs):
```js
import { blob, sqliteTable } from "drizzle-orm/sqlite-core";
const table = sqliteTable('table', {
id: blob('id', { mode: 'bigint' })
});
```
2. Fill and save a bigint using drizzle-orm
image

3. Query by column on drizzle-kit SQL Runner
```sql
select * from "table" where
id = 141448806293050843 --substitute for filled bigint
```
4. Query by column on drizzle-kit SQL Runner converting number to binary
```sql
select * from "table" where
id = hex(141448806293050843) --substitute for filled bigint
```

### Expected behavior

Either 3. or 4. should return the queried row, instead it doesn't return any rows

https://github.com/drizzle-team/drizzle-orm/issues/1980 Would be a good workaround but would require changing the column type and is pending https://github.com/drizzle-team/drizzle-orm/pull/2579

### Environment & setup

MacOS
Windows
Linux

Node 20

Also running Drizzle Kit running on Turso

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.