Add support for nested meta queries#46
Conversation
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
There was a problem hiding this comment.
Pull request overview
This PR adds support for nested meta, tax, and date queries by allowing Query objects to contain other Query objects in addition to Clause objects. This mirrors WordPress core's native nested query functionality.
Key changes:
- Added
addQuery()methods and$queriesproperties to all three query types (MetaQuery, TaxQuery, DateQuery) - Implemented
isFirstOrderClause()methods to distinguish between clauses and nested queries during deserialization - Updated
toArray()methods to serialize both clauses and nested queries with proper index handling
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/MetaQuery/Query.php | Added nested query support with addQuery() method, $queries property, and isFirstOrderClause() logic |
| src/TaxQuery/Query.php | Added nested query support with addQuery() method, $queries property, and isFirstOrderClause() logic |
| src/DateQuery/Query.php | Added nested query support with addQuery() method, $queries property, TIME_KEYS constant, and isFirstOrderClause() logic |
| tests/phpunit/MetaQueryTest.php | Added three new test cases for nested queries and updated test method name for clarity |
| tests/phpunit/TaxQueryTest.php | Added three new test cases for nested queries (associative, indexed, and manual construction) |
| tests/phpunit/DateQueryTest.php | Added three new test cases for nested queries (associative, indexed, and manual construction) |
| tests/WP_Query.php | Added example usage of nested meta queries |
| README.md | Added documentation example demonstrating nested query usage |
| composer.json | Reordered test script to run phpunit before phpstan |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fixes #45