drizzle-team / drizzle-team/drizzle-orm
[FEATURE]:Support update with subqueries
- 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?
v0.39.0
### What version of `drizzle-kit` are you using?
0.30.4
### Other packages
_No response_
### Describe the Bug
An update statement can't have subqueries without workarounds.
example:
```typescript
await db
.update(shows)
.set({
availableCount: sql`${db
.select({ count: count() })
.from(entries)}`,
})
```
(note the extra ``sql`${`` before the subquery)
i'd expect to be able to do that:
```typescript
await db
.update(shows)
.set({
availableCount: db
.select({ count: count() })
.from(entries),
})
```
I found this workaround [here](https://www.answeroverflow.com/m/1149994717749190717).
Contributor guide
Assessment
This issue has not been assessed yet.