-
Notifications
You must be signed in to change notification settings - Fork 125
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
ON DUPLICATE KEY UPDATE clause for batch INSERTS #75
Comments
.ON_DUPLICATE_KEY_UPDATE(
Link.ID.SET(Link.ID.ADD(Int(11))),
Link.Name.SET(StringExp(Raw("values(name)"))),
) |
Thanks for the tip @go-jet. It certainly gets the job done, however I find it very tedious to write queries that way. Are there any plans on adding |
Yep, it will be added eventually. |
Hello @go-jet , I hope you are doing well. This is to remind you that there still is interest in this important (in my opinion) enhancement. |
Code sample: stmt := Link.INSERT().
MODELS([]model.Link{
{
ID: randId,
URL: "https://www.postgresqltutorial.com",
Name: "PostgreSQL Tutorial",
Description: nil,
},
{
ID: randId,
URL: "https://www.yahoo.com",
Name: "Yahoo",
Description: testutils.StringPtr("web portal and search engine"),
},
}).AS_NEW().
ON_DUPLICATE_KEY_UPDATE(
Link.ID.SET(Link.ID.ADD(Int(11))),
Link.URL.SET(Link.NEW.URL),
Link.Name.SET(Link.NEW.Name),
Link.Description.SET(Link.NEW.Description),
) |
In MySQL it is possible to use
ON DUPLICATE KEY UPDATE
clause in batch inserts, like in the below example:However, it appears that it is impossible to perform batch inserts with go-jet's current
ON DUPLICATE KEY UPDATE
implementation.The text was updated successfully, but these errors were encountered: