drizzle-team / drizzle-team/drizzle-orm
[BUG]: enforce-update-with-where false positive when .from() precedes .where() in chain
- 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?
1.0.0-beta.20
### What version of `drizzle-kit` are you using?
1.0.0-beta.20
### Other packages
eslint-plugin-drizzle@0.2.3
### Describe the Bug
The enforce-update-with-where rule incorrectly reports a violation when .from() appears before .where() in an update chain. The rule appears to stop scanning the method chain when it encounters .from(), causing it to miss a .where() that follows.
Reproduce:
```
// ❌ Incorrectly flagged as missing .where()
await tx
.update(table)
.set({ ... })
.from(sql`(VALUES ...) AS v(...)`)
.where(eq(table.id, v.id));
```
```
// ✅ Not flagged (workaround: swap .from() and .where())
await tx
.update(table)
.set({ ... })
.where(eq(table.id, v.id))
.from(sql`(VALUES ...) AS v(...)`);
```
**Expected behavior**: The rule should check that .where() exists anywhere in the chain, regardless of whether .from() appears before or after it.
**Actual behavior**: Rule reports "update without where" when .from() precedes .where().
Contributor guide
Assessment
This issue has not been assessed yet.