Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tag search to not require wildcards #481

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

Tyrannicodin
Copy link
Contributor

Previously, searching for tags required % wildcards to be added either side in order to search for a tag without an exact match, however this removes that requirement.

@CyanVoxel CyanVoxel added Type: QoL A quality of life (QoL) enhancement or suggestion TagStudio: Tags Relating to the TagStudio tag system TagStudio: Search The TagStudio search engine Status: Changes Requested Changes are quested to this labels Sep 9, 2024
@CyanVoxel CyanVoxel added this to the SQL Parity milestone Sep 10, 2024
Copy link
Collaborator

@yedpodtrzitko yedpodtrzitko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a test for this scenario, so there wont be any regression in future, thanks.

@Tyrannicodin
Copy link
Contributor Author

Tyrannicodin commented Sep 11, 2024

please add a test for this scenario, so there wont be any regression in future, thanks.

Sorry, I'm not sure how test for this, since it was purely an issue with the SQL interaction and I can't see any other examples of a SQL test.

@yedpodtrzitko
Copy link
Collaborator

here's a test for tag name lookup, so you can add it there:

def test_tag_search(library):
tag = library.tags[0]
assert library.search_tags(
FilterState(tag=tag.name.lower()),
)
assert library.search_tags(
FilterState(tag=tag.name.upper()),
)
assert not library.search_tags(
FilterState(tag=tag.name * 2),
)

Looking on the test again, it would be better to use @pytest.mark.parametrize() similarly as here, but that's optional:

@pytest.mark.parametrize(
["query_name", "has_result"],
[
("foo", 1), # filename substring
("bar", 1), # filename substring
("one", 0), # path, should not match
],
)
def test_search_file_name(library, query_name, has_result):

@Tyrannicodin
Copy link
Contributor Author

Added a test 👍

@CyanVoxel CyanVoxel added Priority: Medium An issue that shouldn't be be saved for last and removed Status: Changes Requested Changes are quested to this labels Sep 11, 2024
@CyanVoxel CyanVoxel added the Status: Mergeable The code is ready to be merged label Sep 12, 2024
@CyanVoxel
Copy link
Member

Mergeable once the Ruff error is addressed

@CyanVoxel CyanVoxel removed the Status: Mergeable The code is ready to be merged label Sep 12, 2024
@CyanVoxel CyanVoxel merged commit 2f2f763 into TagStudioDev:main Sep 12, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium An issue that shouldn't be be saved for last TagStudio: Search The TagStudio search engine TagStudio: Tags Relating to the TagStudio tag system Type: QoL A quality of life (QoL) enhancement or suggestion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants