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

MySQL 1062 Error while updating #4

Closed
jeffy-mathew opened this issue May 28, 2019 · 2 comments
Closed

MySQL 1062 Error while updating #4

jeffy-mathew opened this issue May 28, 2019 · 2 comments

Comments

@jeffy-mathew
Copy link

It'll be good if the INSERT INTO is changed to REPLACE INTO, so that rows will be updated/created accordingly

@t-tiger
Copy link
Owner

t-tiger commented Oct 6, 2019

@jeffy-mathew

Sorry for the so late response. I considered the pros and cons of introducing the REPLACE INTO in this library.

About the benefits, processing insert / update operation at once. Probably it might be a responsibility of stored procedure or application side, but it can be easily archived by the powerful function of MySQL.

On the other hand, the original gorm is compatible with major RDB such as MySQL, PostgreSQL, and SQLite, and I think it is not desirable to have a function depending on a specific database.

Also, REPLACE INTO executes delete and insert if correspond record exists. This is dangerous when cascade foreign key constraint is set, related records will be deleted at the same time.

From these perspectives, I think the responsibility of REPLACE INTO should be retained by the application.

If you have a different idea, could you write it here? I'll rethink about it again.

@t-tiger
Copy link
Owner

t-tiger commented Oct 14, 2019

Close issue for the above reasons.

@t-tiger t-tiger closed this as completed Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants