drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: bigint mode in SQLite integer column

Open
#1,980 15 comments 14 reactions 0 assignees View on GitHub
db/sqlite enhancement
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Describe what you want

- SQLite's maximum integer value is `9223372036854775807`
- JavaScript's [maximum safe integer] is `9007199254740991`

[maximum safe integer]: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

```javascript
9223372036854775807 // SQLite's largest possible integer
9007199254740991 // JavaScript Number.MAX_SAFE_INTEGER
```

Allow SQLite integer columns to be inferred as JavaScript [BigInt].

[BigInt]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt

```javascript
integer('id', { mode: 'number' })
integer('id', { mode: 'bigint' }) // support this
```

[PostgreSQL] and [MySQL] support this feature in the bigint column.

[PostgreSQL]: https://orm.drizzle.team/docs/column-types/pg#bigint
[MySQL]: https://orm.drizzle.team/docs/column-types/mysql#bigint

```javascript
// will be inferred as `number`
bigint: bigint('bigint', { mode: 'number' })

// will be inferred as `bigint`
bigint: bigint('bigint', { mode: 'bigint' })
```

This will be useful for [Autoincrement] columns that can become large.

[Autoincrement]: https://www.sqlite.org/autoinc.html

Related issues:

- https://github.com/drizzle-team/drizzle-orm/pull/739
- https://github.com/drizzle-team/drizzle-orm/pull/558 - implemented with blob

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.