Skip to content

Commit

Permalink
Fix(DB): Fix bug with adding same genre to book
Browse files Browse the repository at this point in the history
  • Loading branch information
phdru committed Mar 3, 2024
1 parent 164a767 commit a788f36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs-ru/news.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Новости
=======

Версия 0.3.2 (2024-03-??)
-------------------------

* Исправлена ошибка с повторным добавлением жанра книги.

Версия 0.3.1 (2024-02-25)
-------------------------

Expand Down
5 changes: 5 additions & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
@@ -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)
--------------------------

Expand Down
7 changes: 5 additions & 2 deletions m_librarian/inp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit a788f36

Please sign in to comment.