Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 3 years ago

#23294 closed defect (bug) (duplicate)

Using "OR" in 'meta_query' negates the "NOT EXISTS" compare.

Reported by: hereswhatidid's profile hereswhatidid Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:

Description

When using the "NOT EXISTS" compare within 'meta_query' to look for undefined custom fields if I also add in a secondary 'OR' query, the entire query behaves as if I was just checking for "EXISTS". The following code:

'meta_query' => array(
  'relation' => 'OR',
  array(
    'key' => 'status',
    'compare' => 'NOT EXISTS',
  ),
  array(
    'key' => 'status',
    'value' => 'new',
    'compare' => '=',
  ),
);

will return any post that has a value set for the "status" custom field.

Change History (3)

#1 @hereswhatidid
10 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #23268.

#2 @helen
10 years ago

  • Milestone Awaiting Review deleted

This ticket was mentioned in Slack in #core by andraganescu. View the logs.


3 years ago

Note: See TracTickets for help on using tickets.