From: Oleg Broytman Date: Sun, 3 Mar 2024 15:27:40 +0000 (+0300) Subject: Fix(DB): Fix bug with adding same genre to book X-Git-Tag: 0.4.0~11 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=a788f3699c2fb8d9fad06d99e631a771c81e600e;p=m_librarian.git Fix(DB): Fix bug with adding same genre to book --- diff --git a/docs-ru/news.rst b/docs-ru/news.rst index a66ea93..fbdd698 100644 --- a/docs-ru/news.rst +++ b/docs-ru/news.rst @@ -1,6 +1,11 @@ Новости ======= +Версия 0.3.2 (2024-03-??) +------------------------- + +* Исправлена ошибка с повторным добавлением жанра книги. + Версия 0.3.1 (2024-02-25) ------------------------- diff --git a/docs/news.rst b/docs/news.rst index 4d1fe11..ce0b046 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -1,6 +1,11 @@ News ==== +Version 0.3.2 (2024-03-??) +-------------------------- + +* Fix a bug with adding the same genre to a book. + Version 0.3.1 (2024-02-25) -------------------------- diff --git a/m_librarian/inp.py b/m_librarian/inp.py index f910b10..6d3bd7d 100644 --- a/m_librarian/inp.py +++ b/m_librarian/inp.py @@ -2,7 +2,7 @@ import os from zipfile import ZipFile -from sqlobject import sqlhub +from sqlobject import dberrors, sqlhub from sqlobject.sqlbuilder import Select from .db import Author, Book, Extension, Genre, Language, \ @@ -71,7 +71,10 @@ def import_inp_line(archive, parts): for genre in genres.split(':'): if genre: genre_row = insert_name(Genre, genre, title=genre) - book.addGenre(genre_row) + try: + book.addGenre(genre_row) + except dberrors.DuplicateEntryError: + pass # The genre has already been added def tounicode(s):