Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
difrisul-dev1 opened this issue May 23, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@difrisul-dev1
Copy link

Report hasn't been filed before.

  • 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)

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.

@difrisul-dev1 difrisul-dev1 added the bug Something isn't working label May 23, 2025
@valerii15298
Copy link
Contributor

@difrisul-dev1 here is a PR which fixed the same issue for zod: #4554
Are you up to create similar PR which fixes this issue for valibot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants