Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#16563 closed defect (bug) (invalid)

meta_query should default type to 'STRING'

Reported by: batmoo's profile 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)

#1 @dd32
13 years ago

  • Keywords reporter-feedback added

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

#2 @batmoo
13 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 ) );

#3 @dd32
13 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.