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

Upstream #3

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ CHANGELOG
6.3.16 (unreleased)
-------------------

- Fix searching by SearchableText
[frapell]

- Fix vocabulray country code AN


Expand Down
9 changes: 6 additions & 3 deletions guillotina/contrib/catalog/pg/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ class ParsedQueryInfo(BasicParsedQueryInfo):
@configure.adapter(for_=(ICatalogUtility, IResource), provides=ISearchParser, name="default")
class Parser(BaseParser):
def process_compound_field(self, field, value, operator):
parsed_value = urllib.parse.parse_qsl(urllib.parse.unquote(value))
if not isinstance(parsed_value, list):
return None
if isinstance(value, dict):
parsed_value = value.items()
else:
parsed_value = urllib.parse.parse_qsl(urllib.parse.unquote(value))
if not isinstance(parsed_value, list):
return None
wheres = []
arguments = []
selects = []
Expand Down
17 changes: 17 additions & 0 deletions guillotina/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,23 @@ async def test_search_endpoint_null_operator(container_requester):
assert len(response["items"]) == 2


@pytest.mark.app_settings(PG_CATALOG_SETTINGS)
@pytest.mark.skipif(NOT_POSTGRES, reason="Only PG")
async def test_search_searchable_text(container_requester):
async with container_requester as requester:
await requester("POST", "/db/guillotina", data=json.dumps({"@type": "Item", "title": "First item"}))
await requester("POST", "/db/guillotina", data=json.dumps({"@type": "Item", "title": "Second item"}))
await requester("POST", "/db/guillotina", data=json.dumps({"@type": "Item", "title": "Third item"}))

response, status = await requester("GET", "/db/guillotina/@search?SearchableText=item")
assert status == 200
assert len(response["items"]) == 3

response, status = await requester("GET", "/db/guillotina/@search?SearchableText=Third")
assert status == 200
assert len(response["items"]) == 1


async def test_search_post_endpoint(container_requester):
async with container_requester as requester:
response, status = await requester("POST", "/db/guillotina/@search", data="{}")
Expand Down