Support `INSERT INTO table SELECT ...`
Any updates on this?
Hi there,
Strong +1 on this enhencement.
Indeed, this kind of request support would alleviate the need to pass values into the JS world and having it all contained in the SQL world instead.
Nowadays, we've got to do something like this:
const values = db.select({ a, b, c }).from(table).leftJoin(...)
db.insert().values(values);
whereas it would be ideal to have all of drizzle schema capabilities and write something like that:
db.insert().from(db.select({ a, b, c }).from(table.leftJoin(...))
Cheers.
I am trying to achieve to insert the fund.current_balance to the fund_log.previous_balance using select query like the SQL below:
INSERT INTO Table1 (col1, col2, your_desired_value_from_select_clause, col3)
VALUES (
'col1_value',
'col2_value',
(SELECT col_Table2 FROM Table2 WHERE IdTable2 = 'your_satisfied_value_for_col_Table2_selected'),
'col3_value'
);
I was trying to do it on drizzle by this method below:
const fundCurrent = db.select({ current_balance: fund.current_balance }).from(fund).where(eq(fund.id, id))
db.insert(fund_log).values({previous_balance: fundCurrent})
what am I doing wrong here?
Seeing this issue is quite old, yet quite requested. Has there been any update from the Drizzle team or on the PR from @L-Mario564 ?
Any update on this feature? Providing this feature will enhance several application's performance
We are also encountering the need for this - just wanted to add our +1 to prioritizing this as bandwidth is available!
was added in [email protected]
Here's the tag changelog: https://github.com/drizzle-team/drizzle-orm/releases/tag/0.36.3