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

Improve Handling of Empty Queries #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kenara
Copy link

@kenara kenara commented May 25, 2024

Summary

This PR addresses the issue of empty queries in the ZCatalog returning no results without explicit feedback. It proposes raising a ValueError when an empty query is detected, providing clear feedback to developers.

Background

In the current implementation of ZCatalog in Zope 4 and 5, an empty query returns no results without any indication to the user. This behavior can be confusing and complicates debugging.

Justification

  • Improved User Experience: Providing explicit feedback helps users understand why no results are returned, reducing confusion and aiding in debugging.
  • Consistency with Modern Systems: Other indexing systems like Elasticsearch and Solr handle empty queries transparently, either by returning all documents or providing clear feedback.
  • Error Prevention: Encouraging explicit query parameters reduces the risk of unintentional empty queries, which can improve the reliability of applications using ZCatalog.

Changes

  • Add a check in the searchResults method to raise a ValueError when an empty query is detected.
  • Log a warning when an empty query is processed.
  • Update documentation to reflect this new behavior, providing guidance on how to handle empty queries.

Benefits

  • Improved Developer Experience: Clear feedback helps developers understand and debug their queries more effectively.
  • Alignment with Modern Practices: Makes ZCatalog's behavior consistent with other widely-used indexing systems.
  • Error Prevention: Reduces the risk of unintentional empty queries, improving application reliability.

Impact

  • Developers: Clearer understanding of query failures, leading to faster debugging and development cycles.
  • Performance: Minimal impact as the change involves simple conditional checks and logging.
  • Compatibility: Maintains backward compatibility by raising errors only when queries are genuinely empty.

@d-maurer
Copy link
Contributor

d-maurer commented May 25, 2024 via email

Sign up for free to 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.

2 participants