[wp-trac] [WordPress Trac] #29285: meta_query fails with multiple clauses that have non-default 'compare' values
WordPress Trac
noreply at wordpress.org
Wed Aug 20 18:19:08 UTC 2014
#29285: meta_query fails with multiple clauses that have non-default 'compare'
values
--------------------------+-----------------------------
Reporter: boonebgorges | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
It appears that when using 'meta_query' with multiple clauses, where those
clauses have an explicit value set for 'compare', will cause the query to
fail. This is true even when the 'compare' operator is '='. For example:
{{{
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'foo',
'value' => 'bar',
'compare' => '=',
),
array(
'key' => 'foo2',
'value' => 'bar2',
'compare' => '=',
),
),
}}}
This will return no values, while removing the 'compare' params will make
it work. This appears to be the case for all values of compare.
I'm attaching a number of unit tests that demonstrate this problem for a
couple different values of 'relation' and 'compare'.
I haven't dug deep into the root cause, but at a glance, it appears that
the SQL clauses are not being clustered into parentheses correctly - it's
getting short-circuited by the 'compare' logic.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29285>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list