From dd7e7adf931d72fc44a54a9bd16d914eab81f4a2 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Wed, 8 Nov 2023 12:57:49 +0200 Subject: [PATCH] feat(Inventory): update find methods --- src/bookstore/inventory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bookstore/inventory.py b/src/bookstore/inventory.py index e14ee22..031847b 100644 --- a/src/bookstore/inventory.py +++ b/src/bookstore/inventory.py @@ -69,7 +69,7 @@ class Inventory: def find_by_title(self, title: str) -> list[Book] | None: """Looks up `Book`s within `Inventory` by book title and returns them as a `List`. Returns `None` if none were found""" - self.cursor.execute("SELECT * FROM Book WHERE title = ?", (title,)) + self.cursor.execute("SELECT * FROM Book WHERE title LIKE '%?%'", (title,)) books = self.cursor.fetchall() if not books: return None @@ -77,7 +77,7 @@ class Inventory: def find_by_author(self, author: str) -> list[Book] | None: """Looks up `Book`s within `Inventory` by book author and returns them as a `List`. Returns `None` if none were found""" - self.cursor.execute("SELECT * FROM Book WHERE author = ?", (author,)) + self.cursor.execute("SELECT * FROM Book WHERE author LIKE '%?%'", (author,)) books = self.cursor.fetchall() if not books: return None