Skip to content

Commit

Permalink
Ensure that empty subtitles - ie those with a value of None - are set…
Browse files Browse the repository at this point in the history
… to null in the database rather than the string "None" (#2249)
  • Loading branch information
dbernstein authored Jan 14, 2025
1 parent f598128 commit f417b02
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Set none subtitles to null
Revision ID: c800cc42184a
Revises: 579786fecbf4
Create Date: 2025-01-14 18:36:21.116427+00:00
"""

from alembic import op

# revision identifiers, used by Alembic.
revision = "c800cc42184a"
down_revision = "579786fecbf4"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.execute("update editions set subtitle = null where subtitle = 'None'")


def downgrade() -> None:
pass
6 changes: 5 additions & 1 deletion src/palace/manager/core/opds2_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,11 @@ def _extract_publication_metadata(
self.log.debug(f"Started extracting metadata from publication {publication}")

title = str(publication.metadata.title)
subtitle = str(publication.metadata.subtitle)
subtitle = (
str(publication.metadata.subtitle)
if publication.metadata.subtitle
else None
)

languages = first_or_default(publication.metadata.languages)
derived_medium = self._extract_medium_from_links(publication.links)
Expand Down

0 comments on commit f417b02

Please sign in to comment.