fulltext search working

This commit is contained in:
billypom on debian 2025-04-25 18:32:49 -04:00
parent 3d16882185
commit b55b105e05
2 changed files with 5 additions and 4 deletions

View File

@ -678,7 +678,7 @@ class MusicTable(QTableView):
self.model2.setHorizontalHeaderLabels(self.headers.get_user_gui_headers())
fields = ", ".join(self.headers.user_fields)
search_clause = (
"title LIKE %?% AND artist LIKE %?% and album LIKE %?%"
"title LIKE ? OR artist LIKE ? OR album LIKE ?"
if self.search_string
else ""
)
@ -690,7 +690,8 @@ class MusicTable(QTableView):
query = f"SELECT id, {fields} FROM song JOIN song_playlist sp ON id = sp.song_id WHERE sp.playlist_id = ?"
# fulltext search
if self.search_string:
params = 3 * [self.search_string]
# params = 3 * [self.search_string]
params = ["%" + self.search_string + "%"] * 3
if query.find("WHERE") == -1:
query = f"{query} WHERE {search_clause};"
else:
@ -708,7 +709,7 @@ class MusicTable(QTableView):
query = f"SELECT id, {fields} FROM song"
# fulltext search
if self.search_string:
params = 3 * [self.search_string]
params = ["%" + self.search_string + "%"] * 3
if query.find("WHERE") == -1:
query = f"{query} WHERE {search_clause};"
else:

View File

@ -496,7 +496,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
def handle_search_box_text(self, text: str):
"""when text changes, update the music table thingie"""
self.tableView.set_search_string(text)
self.tableView.load_music_table(text)
self.tableView.load_music_table()
def play_audio_file(self, filepath=None) -> None:
"""