Skip to content

Conversation

@mgaligniana
Copy link
Contributor

@mgalignianamgaligniana commented Apr 15, 2024

Description

Based on discussion #7759 I've created this PR to continue the work made in #8775 and #7733

There are no tests with PostgreSQL but I'm creating this to test with the CI

@mgalignianamgalignianaforce-pushed the add-unaccent-to-search-filter branch from 3a71f9b to f8825baCompareApril 15, 2024 14:10
@mgalignianamgaligniana changed the title Add unaccent to SearchFilter (based on #7733)Add unaccent to SearchFilterApr 15, 2024
@mgalignianamgalignianaforce-pushed the add-unaccent-to-search-filter branch from f8825ba to 2ff3f77CompareApril 15, 2024 14:15
@mgalignianamgaligniana marked this pull request as draft April 15, 2024 14:20
@mgalignianamgalignianaforce-pushed the add-unaccent-to-search-filter branch from 2ff3f77 to a2bb1fbCompareApril 15, 2024 18:55
@mgaligniana
Copy link
ContributorAuthor

mgaligniana commented Apr 15, 2024

Hi @auvipy!

In case I would like to add a postgres db creation step, to be able to add new tests: should I add a step here .github/workflows/main.yml?

@mgaligniana
Copy link
ContributorAuthor

mgaligniana commented May 27, 2024

I move this PR to Ready for review as the work is done but I need confirmation on how to add (or if it worth it) a step using PostgreSQL to be able to test it.

Thank you!

@mgalignianamgaligniana marked this pull request as ready for review May 27, 2024 15:49
@jensjeflensje
Copy link

Tried this locally and the unaccent works great. It got me thinking though: anyone using unaccent is probably not interested in a full match either? The current code limits icontains from being used too alongside unaccent. I personally set my lookup prefix to "&": "unaccent__icontains" as that better fits my (and probably also other people's) usecases.

@mgalignianamgalignianaforce-pushed the add-unaccent-to-search-filter branch from a2bb1fb to f195decCompareAugust 29, 2024 18:16
@stale
Copy link

stalebot commented Apr 26, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale label Apr 26, 2025
@auvipyauvipy requested a review from CopilotApril 27, 2025 07:56
Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds unaccent support to the SearchFilter, enabling accent‐insensitive searches on PostgreSQL by mapping the "&" prefix to the "unaccent" lookup.

  • Updates the lookup prefixes in the SearchFilter backend
  • Introduces a PostgreSQL‑specific test for unaccent search
  • Updates the API documentation to include the new lookup operator

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

FileDescription
tests/test_filters.pyAdded a new test class that verifies unaccent search functionality
rest_framework/filters.pyUpdated lookup prefixes to include the unaccent operator
docs/api-guide/filtering.mdAdded new documentation row for accent‑insensitive unaccent search lookup

@stalestalebot removed the stale label Apr 27, 2025
Copy link
Collaborator

@auvipyauvipy left a comment

Choose a reason for hiding this comment

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

test is failing with following error

raise FieldError(
E django.core.exceptions.FieldError: Unsupported lookup 'unaccent' for CharField or join on the field not permitted.

@stale
Copy link

stalebot commented Jul 19, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@mgaligniana
Copy link
ContributorAuthor

mgaligniana commented Jul 26, 2025

test is failing with following error

raise FieldError( E django.core.exceptions.FieldError: Unsupported lookup 'unaccent' for CharField or join on the field not permitted.

Yes!

But is because the test is not being run over a PostgreSQL database, right?

I've tried adding this @pytest.mark.skipif(not postgres_fields, reason='PostgreSQL support (postgres_fields) is not available') to see if it is skiped by the CI, but nope! Any suggesiton?

@mgalignianamgaligniana requested a review from auvipyJuly 26, 2025 14:29
@mgalignianamgalignianaforce-pushed the add-unaccent-to-search-filter branch from dd7d5fc to 468d800CompareOctober 16, 2025 17:27
@mgalignianamgalignianaforce-pushed the add-unaccent-to-search-filter branch from 468d800 to 227b72fCompareOctober 16, 2025 17:35
@mgaligniana
Copy link
ContributorAuthor

mgaligniana commented Oct 16, 2025

I've noticed that @ search never had a test with @ filter.

How bad it would be add this without testing? (as it is the same case)

@mgaligniana
Copy link
ContributorAuthor

Hi @browniebroke! Just wondering if my last comment makes sense, or if you have any suggestions. Thank you!

@browniebroke
Copy link
Member

I've noticed that @ search never had a test with @ filter.

Yes precisely. We've got some blind spots in our test coverage and we're trying to cover these kind of missing cases

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@mgaligniana@jensjeflensje@browniebroke@auvipy