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
21.47k stars 486 forks source link

[BUG]: ESLint rule `enforce-delete-with-where` false positive #2446

Closed MatanYadaev closed 3 weeks ago

MatanYadaev commented 3 weeks ago

What version of drizzle-orm are you using?

0.31.0

What version of drizzle-kit are you using?

0.22.1

Describe the Bug

I use the Repository Pattern to wrap the code that uses Drizzle ORM.

The name of the repository contains that name of the model, and therefore, Drizzle ESLint thinks I access the model, which is wrong.

Code example:

// schema.ts
export const websites = pgTable('websites', {
  id: varchar('id', { length: 128 }).primaryKey(),
});

// app.ts
WebsiteRepository.delete(1); // ESLint: Without `.where(...)` you will delete all the rows in a table. If you didn't want to do it, please use `WebsiteRepository.delete(...).where(...)` instead. Otherwise you can ignore this rule here(drizzle/enforce-delete-with-where)

Expected behavior

The error should not be triggered.

Environment & setup

No response

arjunyel commented 3 weeks ago

https://orm.drizzle.team/docs/eslint-plugin#enforce-delete-with-where