drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: `values()` should accept readonly values during `insert`.
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
The `insert(...).values()` call should accept a readonly object or array. My programming style is very readonly (which easily prevents a entire large category bugs), so not accepting readonly is really inconvenient for me.
I'd suggest replacing this:
```typescript
values(value: PgInsertValue): PgInsertBase;
values(values: PgInsertValue[]): PgInsertBase;
```
with something this:
```typescript
values(value: DeepReadonly>): PgInsertBase;
values(values: readonly DeepReadonly>[]): PgInsertBase;
```
using any of the `DeepReadonly` definitions, e.g. here's a good one from the package `ts-essentials`:
```typescript
export declare type Primitive = string | number | boolean | bigint | symbol | undefined | null;
export declare type Builtin = Primitive | Function | Date | Error | RegExp;
/** Like Readonly but recursive */
export declare type DeepReadonly = T extends Builtin
? T
: T extends Map
? ReadonlyMap, DeepReadonly>
: T extends ReadonlyMap
? ReadonlyMap, DeepReadonly>
: T extends WeakMap
? WeakMap, DeepReadonly>
: T extends Set
? ReadonlySet>
: T extends ReadonlySet
? ReadonlySet>
: T extends WeakSet
? WeakSet>
: T extends Promise
? Promise>
: T extends {}
? {
readonly [K in keyof T]: DeepReadonly;
}
: Readonly;
```
Contributor guide
Assessment
This issue has not been assessed yet.