WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/08/2013 10:51:03 PM (8 years ago)
Author:
wonderboymusic
Message:

Respect the compare operator value in meta_query when value evaluates to null. Adds Unit Test.

Props bradyvercher, gradyetc.
Fixes #22967.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/meta/query.php

    r25002 r26053  
    106106
    107107    }
     108
     109    /**
     110     * @ticket 22967
     111     */
     112    function test_null_value_sql() {
     113        global $wpdb;
     114
     115        $query = new WP_Meta_Query( array(
     116            array( 'key' => 'abc', 'value' => null, 'compare' => '=' )
     117        ) );
     118        $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
     119
     120        $this->assertEquals( 1, substr_count( $sql['where'], "CAST($wpdb->postmeta.meta_value AS CHAR) = '')" ) );
     121    }
    108122}
Note: See TracChangeset for help on using the changeset viewer.