Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]:Support update with subqueries #4243

Open
1 task done
zoriya opened this issue Mar 8, 2025 · 0 comments
Open
1 task done

[BUG]:Support update with subqueries #4243

zoriya opened this issue Mar 8, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@zoriya
Copy link

zoriya commented Mar 8, 2025

Report hasn't been filed before.

  • 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:

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:

await db
	.update(shows)
	.set({
		availableCount: db
			.select({ count: count() })
			.from(entries),
	})

I found this workaround here.

@zoriya zoriya added the bug Something isn't working label Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant