You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MariaDB support more feature than MySQL (old version at least).
The one I would love to have is the support of RETURNING clause on the Create operation.
I see a detection of MariaDB, so why not allow additional features there?
I'm trying to create or get a row while inserting. The goal is to handle properly concurrent insert than try to create the same data.
So What I do is something like:
if err = s.DB.Transaction(func(tx *gorm.DB) (err error) {
if err = tx.Clauses(clause.OnConflict{DoNothing: true}).Create(u).Error; err != nil {
return
}
if u.ID == 0 {
if err = tx.First(u, "sha1 = ?", u.Sha1).Error; err != nil {
return
}
}
Motivation
I've got 3 tables to update. I need the ID of the first one to create the entry in the over tables. And 2 parallel request can run the same code. I don't want to end up with a duplicate error.
The create SQL should be:
INSERT INTO T (C1, C2) VALUES(V2, V2) ON DUPLICATE KEY UPDATE id=id RETURNING *
Or ID by default. That could be overwritten.
The text was updated successfully, but these errors were encountered:
Describe the feature
MariaDB support more feature than MySQL (old version at least).
The one I would love to have is the support of RETURNING clause on the Create operation.
I see a detection of MariaDB, so why not allow additional features there?
I'm trying to create or get a row while inserting. The goal is to handle properly concurrent insert than try to create the same data.
So What I do is something like:
Motivation
I've got 3 tables to update. I need the ID of the first one to create the entry in the over tables. And 2 parallel request can run the same code. I don't want to end up with a duplicate error.
The create SQL should be:
Or ID by default. That could be overwritten.
The text was updated successfully, but these errors were encountered: