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.38k stars 480 forks source link

[FEATURE]: Allow for select statement in insert values clause #2330

Open DanielBaulig opened 1 month ago

DanielBaulig commented 1 month ago

Describe what you want

Maybe I am doing something wrong, but it doesn't appear to be possible to pass a select statement to the values clause of an insert statement like follows

db.insert(table).values(db.select().from(otherTable).where(condition));

Obviously assuming that otherTable's schema sufficiently matches to populate rows in table.

This seems like such an obvious feature that I am suspecting it's possible and I'm just not calling it correctly.

DanielBaulig commented 1 month ago

See https://github.com/drizzle-team/drizzle-orm/pull/1605