ent
ent copied to clipboard
How to do SQL insert statement using query instead of values?
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?