[Bb-trac] [bbPress] #689: More flexible joining of topic meta tables in BB_Query class

bbPress bb-trac at lists.bbpress.org
Wed Jul 11 00:56:54 GMT 2007


#689: More flexible joining of topic meta tables in BB_Query class
-------------------------+--------------------------------------------------
 Reporter:  sambauers    |       Owner:  mdawaffe         
     Type:  enhancement  |      Status:  new              
 Priority:  high         |   Milestone:  0.8.3 & XML-RPC  
Component:  Back-end     |     Version:  1.0-alpha (trunk)
 Severity:  major        |    Keywords:  has-patch        
-------------------------+--------------------------------------------------
 I'm running into limitations when trying to implement a view using the new
 BB_Query/bb_register_view methods.

 At the moment I can't create a query where I fetch topics where meta_value
 IS NULL ''or'' a specific value. Which is actually important for the
 Support Forum plugin "Unresolved topics" view.

 {{{
 $query = array(
         'sticky' => 'all',
         'meta_key' => 'topic_resolved',
         'meta_value'=> 'no,NULL'
 );
 }}}

 Basically I think I just want the NULL value to be interpreted as NULL in
 SQL

 Also, this would include when there is no specific record for the given
 meta_value, so a LEFT JOIN is necessary to bring in topics which don't
 have that meta_key at all.

 Attached patch changes the JOIN type to LEFT JOIN for topic queries that
 include some meta_key and allows for NULL or -NULL to be specified as the
 meta_value.

 It might make more sense to add a "meta_join" value to the query array
 like so:

 {{{
 $query = array(
         'sticky' => 'all',
         'meta_key' => 'topic_resolved',
         'meta_value'=> 'no,NULL',
         'meta_join'=> 'LEFT JOIN'
 );
 }}}

 ... but I don't think changing the standard join to LEFT JOIN is going to
 hurt anything (?).

-- 
Ticket URL: <http://trac.bbpress.org/ticket/689>
bbPress <http://bbpress.org/>
Innovative forum development


More information about the Bb-trac mailing list