Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#16563 closed defect (bug) (invalid)

meta_query should default type to 'STRING'

Reported by: batmoo Owned by:
Priority: normal Milestone:
Component: Query Version: 3.1
Severity: normal Keywords: reporter-feedback
Cc: Focuses:

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
16 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
16 years ago

  • Resolutioninvalid
  • Status newclosed

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
16 years ago

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