question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug][v12][patch] mysql query to create primary key in tabSeries unsuccessful due to duplicate entries

See original GitHub issue

The following query to create a primary key in tabSeries fails due to there being duplicate entries in the table.

ALTER table `tabSeries` ADD PRIMARY KEY IF NOT EXISTS (name)

Reference: https://github.com/frappe/frappe/blob/develop/frappe/patches.txt#L233

Duplicate entries in this table may occur due to older implementations. But they have the exact same values in columns name and current.

To fix this issue, refer to: https://stackoverflow.com/a/8147103

Tagging dev: @sunnyakaxd

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sunnyakaxdcommented, Nov 19, 2018

Have added this PR to fix the same. It’ll deduplicate the tabSeries table initially before making primary key

https://github.com/frappe/frappe/pull/6498

0reactions
sagarvoracommented, Nov 19, 2018

Having tried it in bench console, I can verify that this does the job. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MySQL duplicate entry error even though there is no duplicate ...
It is not created due to a primary key existing that was never actually created or due to damage to the table. What...
Read more >
MySQL Replication Duplicate Entry for Primary Key
You cannot continue with that query, since primary key column is a unique column, it does not accept duplicate values.
Read more >
13.2.7.2 INSERT ... ON DUPLICATE KEY UPDATE Statement
If you specify an ON DUPLICATE KEY UPDATE clause and a row to be inserted would cause a duplicate value in a UNIQUE...
Read more >
MySQL - Handling Duplicates - Tutorialspoint
Let us take an example – The following table contains no such index or primary key, so it would allow duplicate records for...
Read more >
INSERT ON DUPLICATE KEY UPDATE - MariaDB
ON DUPLICATE KEY UPDATE is a MariaDB/MySQL extension to the INSERT ... A regular INSERT with a primary key value of 1 will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found