Fix database error for tags differing only by case#3670
Open
iceout wants to merge 1 commit into
Open
Conversation
new-usemame
added a commit
to new-usemame/Calibre-Web-NextGen
that referenced
this pull request
Jul 18, 2026
Saving a book with tags that differ only by case (Java, java) crashes stock calibre-web with UNIQUE constraint failed: tags.name. This fork is already immune because the calibre session runs autoflush=True and tags.name is COLLATE NOCASE, so the second variant resolves to the row created for the first. These tests pin the user-visible behavior (no crash) and source-pin the load-bearing invariant (autoflush stays on), proven red/green: with autoflush disabled the exact upstream crash reproduces. Verification of janeczku/calibre-web#3670; no production change needed.
new-usemame
added a commit
to new-usemame/Calibre-Web-NextGen
that referenced
this pull request
Jul 18, 2026
Verification of janeczku/calibre-web#3670: this fork is already immune to the case-variant tag crash (autoflush=True + tags.name NOCASE collation). Test-only regression pin; source-pins the autoflush invariant. Credit @the3rdsky (janeczku#3670) for the upstream report. No production change.
|
Thanks for tracking this down @the3rdsky. Noting for anyone landing here from a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prevent a database integrity error when a book is saved with duplicate tags that differ only by letter case, such as
Javaandjava.How to reproduce
Java, java.The save currently fails with:
Root cause
helper.uniq() removes exact duplicates but treats Java and java as different values.
However, tag names use NOCASE collation in the database. Both values therefore resolve to the same tag record, and Calibre-Web attempts to add the same (book, tag) association twice.
Changes
For example:
Java, java, JAVA, Data Science, Data Science
is normalized to:
Java, Data Science
Verification
The repository's Python test suite is maintained separately, so no test file is included in this change.