feat(2meet-data-optimizer): route meta orderby including the HivePress sort clause

- Sort shape (relation OR of NOT EXISTS + EXISTS on one key, named in orderby): drop it from meta_query, LEFT JOIN the flat table and order by its column, ties by ID
- Named routed clause as the sole orderby, and meta_key + meta_value_num (meta_value on string columns) with IS NOT NULL; stay native when the column would not order like CAST(meta_value AS type), orderby has several keys, or meta_value filters
- Verify: tests/live/run.php router (11/11); fe.sh price__asc / hourly_rate__desc / rating__desc ids == native
- PR: PR-062
This commit is contained in:
2026-09-26 20:04:23 +08:00
parent f2e261c522
commit ec75721976
5 changed files with 348 additions and 41 deletions
-11
View File
@@ -381,17 +381,6 @@ class PostQueryRouterTest extends TestCase {
);
}
public function test_orderby_on_a_named_registered_clause_is_not_routed(): void {
$this->assert_not_routed(
array(
'post_type' => 'product',
'meta_query' => array( 'price' => array( 'key' => '_price', 'compare' => 'EXISTS', 'type' => 'NUMERIC' ) ),
'orderby' => array( 'price' => 'ASC' ),
),
'orderby names a routed clause'
);
}
public function test_untyped_integer_equality_on_an_integer_column_is_routed(): void {
$this->set_post_mode( 'aeav_only' );
$query = $this->make_query(