diff --git a/src/gypsum_client/search_metadata.py b/src/gypsum_client/search_metadata.py index 340ebfe..119dc0a 100644 --- a/src/gypsum_client/search_metadata.py +++ b/src/gypsum_client/search_metadata.py @@ -67,7 +67,7 @@ def __invert__(self): def search_metadata_text( path: str, - query: Union[str, GypsumSearchClause], + query: Union[str, List[str], GypsumSearchClause], latest: bool = True, include_metadata: bool = True, ) -> List[Dict]: @@ -169,8 +169,10 @@ def search_metadata_text( if cond: stmt += " WHERE " + " AND ".join(cond) + cursor = conn.execute(stmt, params) + else: + cursor = conn.execute(stmt) - cursor = conn.execute(stmt, params) results = [dict(row) for row in cursor.fetchall()] if include_metadata: for result in results: @@ -207,7 +209,7 @@ def define_text_query( def search_metadata_text_filter( - query: Union[str, GypsumSearchClause], pid_name: str = "paths.pid" + query: Union[str, List[str], GypsumSearchClause], pid_name: str = "paths.pid" ) -> Dict[str, Union[str, List]]: query = sanitize_query(query) @@ -220,7 +222,7 @@ def search_metadata_text_filter( def sanitize_query( - query: Union[str, GypsumSearchClause], + query: Union[str, List[str], GypsumSearchClause], ) -> Optional[GypsumSearchClause]: if isinstance(query, list): if len(query) > 1: diff --git a/tests/test_search.py b/tests/test_search.py index 39735dc..2394351 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -172,6 +172,12 @@ def test_search_metadata_text_text_searches(): assert len(result) == 1 assert result[0]["path"] == "mikoto.txt" + result1 = search_metadata_text( + sqlite_path, "mikoto", include_metadata=False, latest=False + ) + assert len(result1) == 1 + assert result1[0]["path"] == "mikoto.txt" + result = search_metadata_text( sqlite_path, ["kuroko"], include_metadata=False, latest=False )