[wp-trac] [WordPress Trac] #22096: IN meta_query with empty array as meta_value results in invalid database query
WordPress Trac
wp-trac at lists.automattic.com
Thu Oct 4 13:56:54 UTC 2012
#22096: IN meta_query with empty array as meta_value results in invalid database
query
-----------------------------+--------------------------
Reporter: batmoo | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: General
Version: | Severity: normal
Keywords: |
-----------------------------+--------------------------
If you do an {{{IN}}} meta_query and pass in an empty array to the
{{{value}}}, the {{{INNER JOIN}}} clause for the postmeta table isn't
added, which results in an invalid query:
{{{
new WP_Query( array(
'meta_query' => array( array( 'key' => 'abc', 'value' => array(),
'compare' => 'IN' ) )
) );
}}}
This results in an error like so:
{{{
WordPress database error: [Unknown column 'wp_postmeta.meta_key' in 'where
clause']
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND
wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR
wp_posts.post_status = 'private') AND (wp_postmeta.meta_key = 'abc' )
GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 5
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22096>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list