Add diacritic-insensitive matching to library artist search
search_artists now uses unidecode_lower() and _normalize_for_comparison() so 'Tiesto' finds 'Tiësto'. Track search already had this — artist search was the only gap. No change to stored data, only the comparison.
This commit is contained in:
parent
26b2ca60fc
commit
45ba51ce3c
1 changed files with 7 additions and 5 deletions
|
|
@ -4888,25 +4888,27 @@ class MusicDatabase:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def search_artists(self, query: str, limit: int = 50, server_source: str = None) -> List[DatabaseArtist]:
|
def search_artists(self, query: str, limit: int = 50, server_source: str = None) -> List[DatabaseArtist]:
|
||||||
"""Search artists by name, optionally filtered by server source."""
|
"""Search artists by name, optionally filtered by server source.
|
||||||
|
Uses diacritic-insensitive matching so 'Tiesto' finds 'Tiësto'."""
|
||||||
try:
|
try:
|
||||||
conn = self._get_connection()
|
conn = self._get_connection()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
norm_query = f"%{self._normalize_for_comparison(query)}%"
|
||||||
|
|
||||||
if server_source:
|
if server_source:
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
SELECT * FROM artists
|
SELECT * FROM artists
|
||||||
WHERE name LIKE ? AND server_source = ?
|
WHERE unidecode_lower(name) LIKE ? AND server_source = ?
|
||||||
ORDER BY name
|
ORDER BY name
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
""", (f"%{query}%", server_source, limit))
|
""", (norm_query, server_source, limit))
|
||||||
else:
|
else:
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
SELECT * FROM artists
|
SELECT * FROM artists
|
||||||
WHERE name LIKE ?
|
WHERE unidecode_lower(name) LIKE ?
|
||||||
ORDER BY name
|
ORDER BY name
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
""", (f"%{query}%", limit))
|
""", (norm_query, limit))
|
||||||
|
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue