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

fix sql error duplicate entry key on admin/boxes #14469

Closed
wants to merge 3 commits into from

Conversation

atm-greg
Copy link
Contributor

Fix duplicate entry error on boxe add

The user want to add boxes in home page from the admin/boxes.php screen.
If one user already had one of the added boxes it results with a duplicate entry error the prevent from adding the boxe.

Adding "IGNORE" to the insert request skip the insertion for already existing entries

@@ -112,7 +112,7 @@
}
else dol_print_error($db);

$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql = "INSERT IGNORE INTO ".MAIN_DB_PREFIX."boxes (";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work with pgsql ? Is this reserved word a sql standard reserved word or specific to mysql syntax ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after some research, it's not working on pgsql.

The other solution is to verify that the record does not exist before insert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eldy B plan implemented ;)

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Aug 14, 2020
@eldy eldy closed this in 4c0785e Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Some questions or discussions are opened and wait answers of author or other people to be processed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants