noDrizzleUpdateWithoutWhere
Summary
Section titled “Summary”- Rule available since:
v2.4.8 - Diagnostic Category:
lint/nursery/noDrizzleUpdateWithoutWhere - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noDrizzleUpdateWithoutWhere": "error" } } }}Description
Section titled “Description”Require .where() to be called when using .update() with Drizzle ORM.
Without a .where() clause, an update statement will update all rows in the table.
This rule requires explicitly calling .where() to prevent accidental mass updates.
Options
Section titled “Options”Use the drizzleObjectName option to specify the variable names that represent Drizzle
ORM instances.
{ "linter": { "rules": { "nursery": { "noDrizzleUpdateWithoutWhere": { "options": { "drizzleObjectName": [ "db" ] } } } } }}Examples
Section titled “Examples”Invalid
Section titled “Invalid”await db.update(users).set({ name: "John" });code-block.js:1:7 lint/nursery/noDrizzleUpdateWithoutWhere ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ .update() is used without .where(). This will update all rows in the table.
> 1 │ await db.update(users).set({ name: “John” });
│ ^^^^^^^^^^^^^^^^
2 │
ℹ Add a .where() clause to update only the intended rows, or use .where(sql`1=1`) to explicitly update all rows.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
await db.update(users).set({ name: "John" }).where(eq(users.id, 1));Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.