#16563 closed defect (bug) (invalid)
meta_query should default type to 'STRING'
Reported by: | batmoo | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | Query | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
meta_query
defaults the type
argument to CHAR
which does not seem very intuitive to me (tripped me up when I first started using it). The default should probably be changed to STRING
as that's likely to be the most common usecase.
Change History (3)
#2
@
14 years ago
- Resolution set to invalid
- Status changed from new to closed
Turns out I was just using it wrong, though, maybe there needs to be a dumb-proofing of meta_query
for people like me. Instead of an array of arrays, I was just passing in an array:
$args['meta_query'] = array( 'key' => $meta_key );
That creates some strange SQL. I really should have been doing:
$args['meta_query'] = array( array( 'key' => $meta_key ) );
Note: See
TracTickets for help on using
tickets.
meta_query doesnt appear to support STRING, using that will cause it to revert to CHAR, in the MySQL case here, I'm pretty sure CHAR is the same as what you'd expect STRING to be.
http://core.trac.wordpress.org/browser/trunk/wp-includes/meta.php#L355