drizzle-team / drizzle-team/drizzle-orm
[BUG]: Incorrect TypeScript inference for SQLite Blob column builder
- 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.28.1
### What version of `drizzle-kit` are you using?
0.19.12
### Describe the Bug
For SQLite, if I omit the `mode` config option for the `Blob` column builder i.e. `Blob("foo")`, the return type does not match the actual implementation. This affects queries using tables that contain these columns.
`SQLiteBlobJsonBuilderInitial` is the type that's returned even though the implementation actually creates `SQLiteBlobBufferBuilder`:
https://github.com/drizzle-team/drizzle-orm/blob/515afb05df6b0ecc69dacf0e73239828dd727772/drizzle-orm/src/sqlite-core/columns/blob.ts#L135-L149
Was able to workaround this by explicitly specifying the `mode` i.e. `Blob("foo", { mode: "buffer" }`.
A potential fix would be to update the return type such that it looks like this:
```ts
Equal extends true ? SQLiteBigIntBuilderInitial
: Equal extends true ? SQLiteBlobJsonBuilderInitial
: SQLiteBlobBufferBuilderInitial;
```
### Expected behavior
When the `mode` isn't specified, I expect the return type to match the Buffer blob implementation i.e. `SQLiteBlobBufferBuilderInitial`
### Environment & setup
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.