-
Notifications
You must be signed in to change notification settings - Fork 2
Add support for nested sub-WHERE clauses and update hook naming #49
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
Conversation
lucatume
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two requests:
- Add a test to cover malformed sub-WHERE inputs where one or more keys are missing or the operator is not correct.
- The changelog mentions a but-fix, is there a test for this?
Co-authored-by: theAverageDev (Luca Tumedei) <[email protected]>
…t/sub-where-clauses
|
@lucatume this is ready for a second look when you can ! |
lucatume
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the use of the uopz extension to replace it with the use of filters and actions. The uopz extension should be used as a lsat resort when all other options have been exhausted, and it's not the case here.
Summary
This PR introduces support for nested sub-WHERE clauses in query methods and standardizes hook naming to align with the StellarWP namespace. These changes enable more flexible and complex database queries while maintaining backward compatibility through semantic versioning.
Key Changes
Nested Sub-WHERE Clauses - Adds the ability to build complex queries with grouped conditions and custom operators (AND/OR) within the
paginate()andget_total_items()methods.Hook Naming Standardization - Renamed all hooks from
tec_common_*prefix tostellarwp_schema_*prefix for namespace consistency (breaking change, documented in CHANGELOG).Technical Details
Sub-WHERE Clause Implementation
The implementation extracts sub-where clause logic into a new private method
build_sub_wheres_from_args()that recursively builds grouped query conditions. This allows developers to construct queries like:Architecture Decision: The recursive approach allows for arbitrary nesting depth without code duplication. Each sub-where group is wrapped in parentheses and joined with its specified operator, maintaining SQL precedence rules.
Breaking Changes
Hook names have been changed to reflect the correct namespace:
tec_common_custom_table_query_pre_results→stellarwp_schema_custom_table_query_pre_resultstec_common_custom_table_query_post_results→stellarwp_schema_custom_table_query_post_resultstec_common_custom_table_query_results→stellarwp_schema_custom_table_query_resultstec_common_custom_table_query_where→stellarwp_schema_custom_table_query_whereMigration Path: Consumers using these hooks must update their code. The change is documented in CHANGELOG.md with clear before/after examples.
Documentation
Updated documentation includes:
Areas Requiring Review Attention