How to do SQL insert statement using query instead of values?
- Dominant language
- Go
- Stars
- 17.2k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
I have a feature that requires copying some values from one table into another and would like to perform this operation fully within the database for performance reasons, so I'll need to execute a statement like `INSERT INTO "target" ("a", "b") SELECT "a", "b" FROM "source" WHERE ...`. Of course I can just run this in SQL directly, but I'd still like to use Ent for the filtering part so I can reuse existing logic.
Is there any way to do the `INSERT ... SELECT ...`-style query using ent?
Alternatively is there a way I can get convert an Ent query to a string and basically do:
```
`INSERT INTO "target" ("a", "b") ` + client.Source.Query().String()
```
Or another way entirely?
Contributor guide
Assessment
This issue has not been assessed yet.