Changeset 37594
- Timestamp:
- 05/30/2016 04:35:16 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-meta-query.php
r37492 r37594 633 633 634 634 if ( $where ) { 635 $sql_chunks['where'][] = "CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$where}"; 635 if ( 'CHAR' === $meta_type ) { 636 $sql_chunks['where'][] = "$alias.meta_value {$meta_compare} {$where}"; 637 } else { 638 $sql_chunks['where'][] = "CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$where}"; 639 } 636 640 } 637 641 } -
trunk/tests/phpunit/tests/meta/query.php
r32713 r37594 494 494 $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); 495 495 496 $this->assertEquals( 1, substr_count( $sql['where'], " CAST($wpdb->postmeta.meta_value AS CHAR)= ''" ) );496 $this->assertEquals( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_value = ''" ) ); 497 497 } 498 498 … … 602 602 $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); 603 603 604 $this->assertSame( 1, substr_count( $sql['where'], " CAST($wpdb->postmeta.meta_value AS CHAR)= ''" ) );604 $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_value = ''" ) ); 605 605 } 606 606 … … 633 633 $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); 634 634 635 $this->assertSame( 1, substr_count( $sql['where'], " CAST($wpdb->postmeta.meta_value AS CHAR)IN" ) );635 $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_value IN" ) ); 636 636 } 637 637 … … 648 648 $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); 649 649 650 $this->assertSame( 1, substr_count( $sql['where'], " CAST($wpdb->postmeta.meta_value AS CHAR)=" ) );650 $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_value =" ) ); 651 651 } 652 652 … … 664 664 $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); 665 665 666 $this->assertSame( 1, substr_count( $sql['where'], " CAST($wpdb->postmeta.meta_value AS CHAR)=" ) );666 $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_value =" ) ); 667 667 } 668 668 … … 761 761 $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); 762 762 763 $this->assertSame( 1, substr_count( $sql['where'], " CAST($wpdb->postmeta.meta_value AS CHAR)= 'bar'" ) );763 $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_value = 'bar'" ) ); 764 764 } 765 765
Note: See TracChangeset
for help on using the changeset viewer.