[wp-trac] [WordPress Trac] #23268: NOT EXISTS meta query with OR relation

WordPress Trac noreply at wordpress.org
Fri Feb 6 19:35:25 UTC 2015


#23268: NOT EXISTS meta query with OR relation
-------------------------------------------------+-------------------------
 Reporter:  timfield                             |       Owner:
     Type:  defect (bug)                         |  wonderboymusic
 Priority:  normal                               |      Status:  closed
Component:  Query                                |   Milestone:  3.9
 Severity:  normal                               |     Version:  3.5
 Keywords:  has-patch needs-unit-tests meta-     |  Resolution:  fixed
  query                                          |     Focuses:
-------------------------------------------------+-------------------------

Comment (by o----o):

 one more weirdness
 this works
 {{{
 $query['meta_query'] = array(


                     'relation' => 'OR',
                     array(
                         'key' => 'app_exclude',
                         'compare' => 'NOT EXISTS'
                         'value'   => 'completely'
                     ),
                     array(
                         'key' => 'app_exclude',
                         'compare' => '!=',
                         'value' => '1'
                     ),
                 );
 }}}

 this doesn't

 {{{
 $query['meta_query'] = array(
                     'relation' => 'OR',
                     array(
                         'key' => 'app_exclude',
                         'compare' => '!=',
                         'value' => '1'
                     ),
                     array(
                         'key' => 'app_exclude',
                         'compare' => 'NOT EXISTS'
                         'value'   => 'completely'
                     ),

                 );
 }}}


 NOT EXISTS has to be defined on first place, or you won't get the result
 (WP 4.1)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/23268#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list