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 deduplicating books that are on a shelf or in a list #2818

Merged
merged 1 commit into from
Apr 25, 2023

Conversation

bpeel
Copy link
Contributor

@bpeel bpeel commented Apr 15, 2023

Previously when the deduplicate_book_data script tried to merge an edition that was on a shelf or in a list then it would fail because when the canonical book was added to the shelf or the list then it wouldn’t set the extra fields of the linking table for the “through” model of the field. These would end up defaulting to NULL, but that is not valid for some of the fields in ShelfItem and ListItem so postgres wouldn’t accept it.

To fix that, this patch makes it skip updating fields that have a non-autogenerated linking table. The linking table would appear as a separate model anyway so the book will be moved via that instead.

Fixes: #2817

Previously when the deduplicate_book_data script tried to merge an
edition that was on a shelf or in a list then it would fail because when
the canonical book was added to the shelf or the list then it wouldn’t
set the extra fields of the linking table for the “through” model of the
field. These would end up defaulting to NULL, but that is not valid for
some of the fields in ShelfItem and ListItem so postgres wouldn’t accept
it.

To fix that, this patch makes it skip updating fields that have a
non-autogenerated linking table. The linking table would appear as a
separate model anyway so the book will be moved via that instead.

Fixes: bookwyrm-social#2817
@jaschaurbach
Copy link
Member

no need to merge if #2821 is merged.

@mouse-reeve mouse-reeve merged commit 2bbc9a1 into bookwyrm-social:main Apr 25, 2023
@bpeel bpeel deleted the fix-deduplicate branch May 15, 2023 17:11
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

Successfully merging this pull request may close these issues.

deduplicate_book_data doesn’t work if the book to be removed is in a list
3 participants