mirror of
https://github.com/kristoferssolo/LU-bookstore.git
synced 2025-10-21 18:00:34 +00:00
feat(Inventory): update find methods
This commit is contained in:
parent
8fb6e2c2ed
commit
dd7e7adf93
@ -69,7 +69,7 @@ class Inventory:
|
|||||||
|
|
||||||
def find_by_title(self, title: str) -> list[Book] | None:
|
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"""
|
"""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()
|
books = self.cursor.fetchall()
|
||||||
if not books:
|
if not books:
|
||||||
return None
|
return None
|
||||||
@ -77,7 +77,7 @@ class Inventory:
|
|||||||
|
|
||||||
def find_by_author(self, author: str) -> list[Book] | None:
|
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"""
|
"""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()
|
books = self.cursor.fetchall()
|
||||||
if not books:
|
if not books:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user