drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.56k stars 645 forks source link

[BUG]:doesn't see the value from entity #3269

Closed Kaidstor closed 2 weeks ago

Kaidstor commented 2 weeks ago

What version of drizzle-orm are you using?

0.35.3

What version of drizzle-kit are you using?

0.26.2

Describe the Bug

I try to update value, but see error in types (using "drizzle-orm/node-postgres")

"typescript": "^5.6.3"

Object literal may only specify known properties, and 'solved' does not exist in type '{ msName?: SQL | string; projectId?: number | SQL; }'.

    const raw = await db
      .update(schema.linkedToPid)
      .set({
        solved: solved ? sql`CURRENT_TIMESTAMP` : null,
      })
      .where(
        and(
          eq(schema.linkedToPid.id, id),
          eq(schema.linkedToPid.projectId, projectId),
        ),
      );

schema

export const linkedToPid3 = pgTable(
  'ms-item-linked-to-pid',
  {
    id: bigint({ mode: 'number' }).generatedAlwaysAsIdentity(),
    msItemId: varchar({ length: 255 }).notNull(),
    msName: text().notNull(),
    solved: timestamp({ precision: 0 }),
    projectId: bigint({ mode: 'number' }).notNull(),
  },
  (t) => ({
    msItem: uniqueIndex().on(t.msItemId, t.msName, t.projectId),
  }),
);

Expected behavior

expect to update field that exists in my entity

Environment & setup

tsconfig.json

{ "compilerOptions": { "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "target": "ESNext", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true, "skipLibCheck": true, "strictNullChecks": false, "noImplicitAny": false, "strictBindCallApply": false, "strict": true, "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false, "esModuleInterop": true, "paths": { "@app/": ["./src/"], } }, "exclude": ["dist"] }

rphlmr commented 2 weeks ago

👋 can you try with strictNullChecks set to true?

Kaidstor commented 2 weeks ago

yep it works ^) thanks bug fixed @rphlmr