Pods 2.5.4 Maintenance Release
We have released another point release to the Pods 2.x branch. This particular patch now increases our Unit Test coverage by more than a 1000 tests. (2.5.3: 1,873 tests, 13,542 assertions to 2.5.4: 2,831 tests, 16,233 assertions). Most of the unit tests were primarily focused on our coverage for our find() class, which is the workhorse for traversals, relationships and queries.
Here’s a very basic example of where compare ALL comes in handy for custom field lookups which get joined, making it hard to do what you want because it’s just one join:
$params = array( 'where' => array( array( 'key' => 'favorite_color', 'value' => array( 'Red', 'Green', 'Blue' ), 'compare' => 'ALL' ) ) ); // Get all items that have *ALL* three of these favorite colors: // Red, Green, and Blue $pod->find( $params );
This is super useful for relationships, since they get joined by one LEFT JOIN in the final DB query. Because of that join, it’s impossible to check that an item has multiple values in that context, as it will only ever have one value — unless you GROUP BY and do a GROUP_CONCAT an alias in select, and plug all this into a ‘having’ instead of ‘where’. Even then, it’s difficult to work with and overly complicated. Now it’s as easy as setting ‘ALL’ in your ‘compare’ 🙂 We’d love to contribute this back to WordPress at some point for WP_Query, but it may be too much of an edge-case for core.
You can read the full changelog for this maintenance release here.