drizzle-team / drizzle-team/drizzle-orm

[BUG]: drizzle valibot select schema's inferred type does not recognized properties using `integer().generatedAlwaysAsIdentity()`

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

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

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

0.43.1

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

0.31.1

### Other packages

drizzle-valibot@0.4.2

### Describe the Bug

The very example on the documentation causes this:

(from https://orm.drizzle.team/docs/valibot)

```ts
import { pgTable, text, integer } from 'drizzle-orm/pg-core';
import { createSelectSchema } from 'drizzle-valibot';
import { parse } from 'valibot';
const users = pgTable('users', {
id: integer().generatedAlwaysAsIdentity().primaryKey(),
name: text().notNull(),
age: integer().notNull()
});
const userSelectSchema = createSelectSchema(users);

const rows = await db.select().from(users).limit(1);

// error: Property 'id' is missing in type '{ name: string; age: number; }' but required in type '{ id: number; name: string; age: number; }'. (ts 2741)
const parsed: { id: number; name: string; age: number } = parse(userSelectSchema, rows[0]);
```

This does not happen, for example, if the id is declared with `uuid().defaultRandom()`. The DB *does* return the ID on a query regardless of course, so this is just a typing bug.

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.