Skip to content
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

Duplicate primary key error returned when saving unmodified object #6171

Closed
flin7 opened this issue Mar 21, 2023 · 5 comments
Closed

Duplicate primary key error returned when saving unmodified object #6171

flin7 opened this issue Mar 21, 2023 · 5 comments
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@flin7
Copy link

flin7 commented Mar 21, 2023

GORM Playground Link

go-gorm/playground#582

Description

@github-actions github-actions bot added the type:with reproduction steps with reproduction steps label Mar 21, 2023
@dablelv
Copy link

dablelv commented Mar 23, 2023

I also encountered the same error. When I using Save method to save the unmodified object I will get the below error.

Error 1062 (23000): Duplicate entry 'xxx' for key 'PRIMARY'.

Confusingly, this occurs in the concurrent case, but not in the serial case.

@zlasd
Copy link

zlasd commented Mar 23, 2023

I think we should revert commit f387433. Before the commit, Save function will examine whether the record exists and only insert it when non-exist. @jinzhu

@black-06
Copy link
Contributor

It was fixed in #6149 and just merged.

@monoflash
Copy link

monoflash commented Mar 30, 2023

MySQL MariaDB database, same problem.
Save() does not work from version 1.24.6 to latest.
The latest version in which Save() works is v1.24.5.

This change has led to problems with the Save() function:
f387433

@flin7
Copy link
Author

flin7 commented Mar 31, 2023

MySQL MariaDB database, same problem. Save() does not work from version 1.24.6 to latest. The latest version in which Save() works is v1.24.5.

This change has led to problems with the Save() function: f387433

This issue has been fixed in the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:with reproduction steps with reproduction steps
Projects
None yet
Development

No branches or pull requests

7 participants