<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[29799] trunk/tests/phpunit/tests: Improve unit tests related to WP_Meta_Query.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/29799">29799</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/29799","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>boonebgorges</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2014-09-30 21:17:38 +0000 (Tue, 30 Sep 2014)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Improve unit tests related to WP_Meta_Query.

* More complete test coverage for publicly available methods of WP_Meta_Query.
* Move tests that rely on WP_Query (via the meta_query parameter) to tests/post/query.php.
* Better coverage for basic use cases of 'meta_query', including all values of 'compare' and default values of 'key', 'value', and 'compare'.
* Improve performance for tests that run WP_Query, by retrieving only post IDs and not prefetching postmeta and post terms.
* Add 'public' visibility keywords to test methods.
* Whitespace cleanup.

Fixes <a href="https://core.trac.wordpress.org/ticket/29560">#29560</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsmetaqueryphp">trunk/tests/phpunit/tests/meta/query.php</a></li>
<li><a href="#trunktestsphpunittestspostqueryphp">trunk/tests/phpunit/tests/post/query.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsmetaqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/meta/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/meta/query.php  2014-09-30 14:59:10 UTC (rev 29798)
+++ trunk/tests/phpunit/tests/meta/query.php    2014-09-30 21:17:38 UTC (rev 29799)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,17 +2,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Test WP_Meta_Query, in wp-includes/meta.php
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * See tests/post/query.php for tests that involve post queries.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px">  * @group meta
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Meta_Query extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_default_relation() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_empty_meta_query_param() {
+               $query = new WP_Meta_Query();
+               $this->assertSame( null, $query->relation );
+       }
+
+       public function test_default_relation() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $query = new WP_Meta_Query( array( array( 'key' => 'abc' ) ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">                 $this->assertEquals( 'AND', $query->relation );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_set_relation() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_set_relation() {
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Meta_Query( array( array( 'key' => 'abc' ), 'relation' => 'AND' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,11 +30,25 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Non-arrays should not be added to the queries array.
+        */
+       public function test_invalid_query_clauses() {
+               $query = new WP_Meta_Query( array(
+                       'foo', // empty string
+                       5, // int
+                       false, // bool
+                       array(),
+               ) );
+
+               $this->assertSame( array( array() ), $query->queries );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Test all key only meta queries use the same INNER JOIN when using relation=OR
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 19729
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_single_inner_join_for_keys_only() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_single_inner_join_for_keys_only() {
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -57,10 +77,78 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * WP_Query-style query must be at index 0 for order_by=meta_value to work.
+        */
+       public function test_parse_query_vars_simple_query_index_0() {
+               $qv = array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo1',
+                                       'compare' => 'baz1',
+                                       'value' => 'bar1',
+                               ),
+                       ),
+                       'meta_key' => 'foo',
+                       'meta_compare' => 'bar',
+                       'meta_value' => 'baz',
+               );
+
+               $query = new WP_Meta_Query();
+               $query->parse_query_vars( $qv );
+
+               $expected0 = array(
+                       'key' => 'foo',
+                       'compare' => 'bar',
+                       'value' => 'baz',
+               );
+               $this->assertEquals( $expected0, $query->queries[0] );
+
+               $expected1 = array(
+                       'key' => 'foo1',
+                       'compare' => 'baz1',
+                       'value' => 'bar1',
+               );
+               $this->assertEquals( $expected1, $query->queries[1] );
+       }
+
+       /**
+        * When no meta_value is provided, no 'value' should be set in the parsed queries.
+        */
+       public function test_parse_query_vars_with_no_meta_value() {
+               $qv = array(
+                       'meta_key' => 'foo',
+                       'meta_type' => 'bar',
+                       'meta_compare' => '=',
+               );
+
+               $query = new WP_Meta_Query();
+               $query->parse_query_vars( $qv );
+
+               $this->assertTrue( ! isset( $query->queries[0]['value'] ) );
+       }
+
+       /**
+        * WP_Query sets meta_value to '' by default. It should be removed by parse_query_vars().
+        */
+       public function test_parse_query_vars_with_default_meta_compare() {
+               $qv = array(
+                       'meta_key' => 'foo',
+                       'meta_type' => 'bar',
+                       'meta_compare' => '=',
+                       'meta_value' => '',
+               );
+
+               $query = new WP_Meta_Query();
+               $query->parse_query_vars( $qv );
+
+               $this->assertTrue( ! isset( $query->queries[0]['value'] ) );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Test the conversion between "WP_Query" style meta args (meta_value=x&meta_key=y)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * to a meta query array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * to a meta query array.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_parse_query_vars() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_parse_query_vars() {
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Meta_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -81,9 +169,51 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @ticket 23033
+        */
+       public function test_get_cast_for_type() {
+               $query = new WP_Meta_Query();
+               $this->assertEquals( 'BINARY', $query->get_cast_for_type( 'BINARY' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'CHAR' ) );
+               $this->assertEquals( 'DATE', $query->get_cast_for_type( 'DATE' ) );
+               $this->assertEquals( 'DATETIME', $query->get_cast_for_type( 'DATETIME' ) );
+               $this->assertEquals( 'SIGNED', $query->get_cast_for_type( 'SIGNED' ) );
+               $this->assertEquals( 'UNSIGNED', $query->get_cast_for_type( 'UNSIGNED' ) );
+               $this->assertEquals( 'TIME', $query->get_cast_for_type( 'TIME' ) );
+               $this->assertEquals( 'SIGNED', $query->get_cast_for_type( 'NUMERIC' ) );
+               $this->assertEquals( 'NUMERIC(10)', $query->get_cast_for_type( 'NUMERIC(10)' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10)' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10 )' ) );
+               $this->assertEquals( 'NUMERIC(10, 5)', $query->get_cast_for_type( 'NUMERIC(10, 5)' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC(10,  5)' ) );
+               $this->assertEquals( 'NUMERIC(10,5)', $query->get_cast_for_type( 'NUMERIC(10,5)' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10, 5 )' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC(10, 5 )' ) );
+               $this->assertEquals( 'DECIMAL', $query->get_cast_for_type( 'DECIMAL' ) );
+               $this->assertEquals( 'DECIMAL(10)', $query->get_cast_for_type( 'DECIMAL(10)' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL( 10 )' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL( 10)' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL(10 )' ) );
+               $this->assertEquals( 'DECIMAL(10, 5)', $query->get_cast_for_type( 'DECIMAL(10, 5)' ) );
+               $this->assertEquals( 'DECIMAL(10,5)', $query->get_cast_for_type( 'DECIMAL(10,5)' ) );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL(10,  5)' ) );
+
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type() );
+               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'ANYTHING ELSE' ) );
+       }
+
+       /**
+        * Invalid $type will fail to get a table from _get_meta_table()
+        */
+       public function test_get_sql_invalid_type() {
+               $query = new WP_Meta_Query();
+               $this->assertFalse( $query->get_sql( 'foo', 'foo', 'foo' ) );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * @ticket 22096
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_empty_value_sql() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_empty_value_sql() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Meta_Query();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -109,7 +239,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 22967
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_null_value_sql() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_null_value_sql() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Meta_Query( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -121,42 +251,279 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @ticket 23033
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * "key only queries" are queries that don't need to match a value, so
+        * they can be grouped together into a single clause without JOINs
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_get_cast_for_type() {
-               $query = new WP_Meta_Query();
-               $this->assertEquals( 'BINARY', $query->get_cast_for_type( 'BINARY' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'CHAR' ) );
-               $this->assertEquals( 'DATE', $query->get_cast_for_type( 'DATE' ) );
-               $this->assertEquals( 'DATETIME', $query->get_cast_for_type( 'DATETIME' ) );
-               $this->assertEquals( 'SIGNED', $query->get_cast_for_type( 'SIGNED' ) );
-               $this->assertEquals( 'UNSIGNED', $query->get_cast_for_type( 'UNSIGNED' ) );
-               $this->assertEquals( 'TIME', $query->get_cast_for_type( 'TIME' ) );
-               $this->assertEquals( 'SIGNED', $query->get_cast_for_type( 'NUMERIC' ) );
-               $this->assertEquals( 'NUMERIC(10)', $query->get_cast_for_type( 'NUMERIC(10)' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10)' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10 )' ) );
-               $this->assertEquals( 'NUMERIC(10, 5)', $query->get_cast_for_type( 'NUMERIC(10, 5)' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC(10,  5)' ) );
-               $this->assertEquals( 'NUMERIC(10,5)', $query->get_cast_for_type( 'NUMERIC(10,5)' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10, 5 )' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC(10, 5 )' ) );
-               $this->assertEquals( 'DECIMAL', $query->get_cast_for_type( 'DECIMAL' ) );
-               $this->assertEquals( 'DECIMAL(10)', $query->get_cast_for_type( 'DECIMAL(10)' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL( 10 )' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL( 10)' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL(10 )' ) );
-               $this->assertEquals( 'DECIMAL(10, 5)', $query->get_cast_for_type( 'DECIMAL(10, 5)' ) );
-               $this->assertEquals( 'DECIMAL(10,5)', $query->get_cast_for_type( 'DECIMAL(10,5)' ) );
-               $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL(10,  5)' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_sql_key_only_queries() {
+               global $wpdb;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'ANYTHING ELSE' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $query1 = new WP_Meta_Query( array(
+                       'relation' => 'OR',
+
+                       // Empty 'compare'
+                       array(
+                               'key' => 'foo',
+                       ),
+
+                       // Non-empty 'compare'
+                       array(
+                               'key' => 'bar',
+                               'compare' => '<',
+                       ),
+
+                       // NOT EXISTS
+                       array(
+                               'key' => 'baz',
+                               'compare' => 'NOT EXISTS',
+                       ),
+
+                       // Has a value
+                       array(
+                               'key' => 'barry',
+                               'value' => 'foo',
+                       ),
+
+                       // Has no key
+                       array(
+                               'value' => 'bar',
+                       ),
+               ) );
+
+               $sql = $query1->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               // 'foo' and 'bar' should be queried against the non-aliased table
+               $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'foo'" ) );
+               $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'bar'" ) );
+
+               // NOT EXISTS compare queries are not key-only so should not be non-aliased
+               $this->assertSame( 0, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'baz'" ) );
+
+               // When a value exists, it's not a key-only query
+               $this->assertSame( 0, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'barry'" ) );
+
+               // 'AND' queries don't have key-only queries
+               $query2 = new WP_Meta_Query( array(
+                       'relation' => 'AND',
+
+                       // Empty 'compare'
+                       array(
+                               'key' => 'foo',
+                       ),
+
+                       // Non-empty 'compare'
+                       array(
+                               'key' => 'bar',
+                               'compare' => '<',
+                       ),
+               ) );
+
+               $sql = $query2->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               // Only 'foo' should be queried against the non-aliased table
+               $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'foo'" ) );
+               $this->assertSame( 0, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'bar'" ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_not_exists() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * Key-only and regular queries should have the key trimmed
+        */
+       public function test_get_sql_trim_key() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Meta_Query( array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        array(
+                               'key' => '  foo  ',
+                       ),
+                       array(
+                               'key' => '  bar  ',
+                               'value' => 'value',
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "meta_key = 'foo'" ) );
+               $this->assertSame( 1, substr_count( $sql['where'], "meta_key = 'bar'" ) );
+       }
+
+       public function test_convert_null_value_to_empty_string() {
+               global $wpdb;
+
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'value' => null,
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "CAST($wpdb->postmeta.meta_value AS CHAR) = ''" ) );
+       }
+
+       public function test_get_sql_convert_lowercase_compare_to_uppercase() {
+               global $wpdb;
+
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'value' => 'bar',
+                               'compare' => 'regExp',
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "REGEXP" ) );
+       }
+
+       public function test_get_sql_empty_meta_compare_with_array_value() {
+               global $wpdb;
+
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'value' => array( 'bar', 'baz' ),
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "CAST($wpdb->postmeta.meta_value AS CHAR) IN" ) );
+       }
+
+       public function test_get_sql_empty_meta_compare_with_non_array_value() {
+               global $wpdb;
+
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'value' => 'bar',
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "CAST($wpdb->postmeta.meta_value AS CHAR) =" ) );
+       }
+
+       public function test_get_sql_invalid_meta_compare() {
+               global $wpdb;
+
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'value' => 'bar',
+                               'compare' => 'INVALID COMPARE',
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "CAST($wpdb->postmeta.meta_value AS CHAR) =" ) );
+       }
+
+       /**
+        * This is the clause that ensures that empty arrays are not valid queries.
+        */
+       public function test_get_sql_null_value_and_empty_key_should_not_have_table_join() {
+               global $wpdb;
+
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'value' => 'bar',
+                       ),
+                       array(),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               // There should be no JOIN against an aliased table.
+               $this->assertSame( 0, substr_count( $sql['join'], "AS mt" ) );
+       }
+
+       public function test_get_sql_compare_array_comma_separated_values() {
+               global $wpdb;
+
+               // Single value.
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'compare' => 'IN',
+                               'value' => 'bar',
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "('bar')" ) );
+
+               // Multiple values, no spaces.
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'compare' => 'IN',
+                               'value' => 'bar,baz',
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "('bar','baz')" ) );
+
+               // Multiple values, spaces.
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'compare' => 'IN',
+                               'value' => 'bar,baz,   barry',
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "('bar','baz','barry')" ) );
+       }
+
+       public function test_get_sql_compare_array() {
+               global $wpdb;
+
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'compare' => 'IN',
+                               'value' => array( 'bar', 'baz' ),
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "('bar','baz')" ) );
+       }
+
+       /**
+        * Non-array values are trimmed. @todo Why?
+        */
+       public function test_get_sql_trim_string_value() {
+               global $wpdb;
+
+               $query = new WP_Meta_Query( array(
+                       array(
+                               'key' => 'foo',
+                               'value' => '  bar  ',
+                       ),
+               ) );
+
+               $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+
+               $this->assertSame( 1, substr_count( $sql['where'], "CAST($wpdb->postmeta.meta_value AS CHAR) = 'bar'" ) );
+       }
+
+       public function test_not_exists() {
+               global $wpdb;
+
+               $query = new WP_Meta_Query( array(
</ins><span class="cx" style="display: block; padding: 0 10px">                         'relation' => 'OR',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'key' => 'exclude',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -174,7 +541,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertContains( "{$wpdb->postmeta}.post_id IS NULL", $sql['where'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_empty_compare() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_empty_compare() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Meta_Query( array(
</span></span></pre></div>
<a id="trunktestsphpunittestspostqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/query.php  2014-09-30 14:59:10 UTC (rev 29798)
+++ trunk/tests/phpunit/tests/post/query.php    2014-09-30 21:17:38 UTC (rev 29799)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,14 +1,433 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * @group meta
- */
</del><span class="cx" style="display: block; padding: 0 10px"> class Tests_Post_Query extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px">        function setUp() {
</span><span class="cx" style="display: block; padding: 0 10px">                parent::setUp();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_meta_key_or_query() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * @group meta
+        */
+       public function test_meta_query_no_key() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'oof', 'bar' );
+               add_post_meta( $p3, 'oof', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'value' => 'bar',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1, $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_no_value() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'oof', 'bar' );
+               add_post_meta( $p3, 'oof', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'oof',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2, $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_single_query_compare_default() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'bar',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_single_query_compare_equals() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'bar',
+                                       'compare' => '=',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_single_query_compare_not_equals() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'foo', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'bar',
+                                       'compare' => '!=',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_single_query_compare_arithmetic_comparisons() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', '1' );
+               add_post_meta( $p2, 'foo', '2' );
+               add_post_meta( $p3, 'foo', '3' );
+
+               // <
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 2,
+                                       'compare' => '<',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               // <=
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 2,
+                                       'compare' => '<=',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1, $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               // >=
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 2,
+                                       'compare' => '>=',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2, $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               // >
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 2,
+                                       'compare' => '>',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_single_query_compare_like() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'ba',
+                                       'compare' => 'LIKE',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_single_query_compare_not_like() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'foo', 'rab' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'ba',
+                                       'compare' => 'NOT LIKE',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_single_query_compare_between_not_between() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', '1' );
+               add_post_meta( $p2, 'foo', '10' );
+               add_post_meta( $p3, 'foo', '100' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => array( 9, 12 ),
+                                       'compare' => 'BETWEEN',
+                                       'type' => 'NUMERIC',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => array( 9, 12 ),
+                                       'compare' => 'NOT BETWEEN',
+                                       'type' => 'NUMERIC',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1, $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_single_query_compare_regexp_rlike() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'foo', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'z$',
+                                       'compare' => 'REGEXP',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               // RLIKE is a synonym for REGEXP.
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'z$',
+                                       'compare' => 'RLIKE',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_single_query_compare_not_regexp() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'foo', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'z$',
+                                       'compare' => 'NOT REGEXP',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_relation_default() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'foo value 1' );
+               add_post_meta( $p1, 'bar', 'bar value 1' );
+               add_post_meta( $p2, 'foo', 'foo value 1' );
+               add_post_meta( $p2, 'bar', 'bar value 2' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'foo value 1',
+                               ),
+                               array(
+                                       'key' => 'bar',
+                                       'value' => 'bar value 1',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEquals( $expected, $query->posts );
+       }
+
+       /**
+        * @group meta
+        */
+       public function test_meta_query_relation_or() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $post_id = $this->factory->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                add_post_meta( $post_id, 'foo', rand_str() );
</span><span class="cx" style="display: block; padding: 0 10px">                add_post_meta( $post_id, 'foo', rand_str() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,6 +443,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                add_post_meta( $post_id6, 'bar', 'val1' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                         'meta_query' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'key' => 'foo'
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,18 +464,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts = $query->get_posts();
-               $this->assertEquals( 4, count( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-
-               $post_ids = wp_list_pluck( $posts, 'ID' );
-               $this->assertEqualSets( array( $post_id, $post_id2, $post_id3, $post_id4 ), $post_ids );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $expected = array( $post_id, $post_id2, $post_id3, $post_id4 );
+               $this->assertEqualSets( $expected, $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_meta_key_and_query() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * @group meta
+        */
+       public function test_meta_query_relation_and() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $post_id = $this->factory->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                add_post_meta( $post_id, 'foo', rand_str() );
</span><span class="cx" style="display: block; padding: 0 10px">                add_post_meta( $post_id, 'foo', rand_str() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -92,18 +510,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'relation' => 'AND',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts = $query->get_posts();
-               $this->assertEquals( 1, count( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $expected = array( $post_id7 );
+               $this->assertEqualSets( $expected, $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $post_ids = wp_list_pluck( $posts, 'ID' );
-               $this->assertEquals( array( $post_id7 ), $post_ids );
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,23 +528,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'relation' => 'AND',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts = $query->get_posts();
-               $this->assertEquals( 3, count( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-
-               $post_ids = wp_list_pluck( $posts, 'ID' );
-               $this->assertEqualSets( array( $post_id2, $post_id6, $post_id7 ), $post_ids );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $expected = array( $post_id2, $post_id6, $post_id7 );
+               $this->assertEqualSets( $expected, $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 18158
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @group meta
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_meta_key_not_exists() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_meta_query_compare_not_exists() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $post_id = $this->factory->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                add_post_meta( $post_id, 'foo', rand_str() );
</span><span class="cx" style="display: block; padding: 0 10px">                $post_id2 = $this->factory->post->create();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -144,65 +555,66 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        array(
-                               'key' => 'foo',
-                               'compare' => 'NOT EXISTS',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'foo',
+                                       'compare' => 'NOT EXISTS',
+                               ),
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts = $query->get_posts();
-               $this->assertEquals( 3, count( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $expected = array( $post_id2, $post_id3, $post_id4 );
+               $this->assertEqualSets( $expected, $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        array(
-                               'key' => 'foo',
-                               'compare' => 'NOT EXISTS',
-                       ),
</del><span class="cx" style="display: block; padding: 0 10px">                                 array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'key' => 'bar',
-                               'compare' => 'NOT EXISTS',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'key' => 'foo',
+                                       'compare' => 'NOT EXISTS',
+                               ),
+                               array(
+                                       'key' => 'bar',
+                                       'compare' => 'NOT EXISTS',
+                               ),
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts = $query->get_posts();
-               $this->assertEquals( 1, count( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $expected = array( $post_id4 );
+               $this->assertEquals( $expected, $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        array(
-                               'key' => 'foo',
-                               'compare' => 'NOT EXISTS',
-                       ),
</del><span class="cx" style="display: block; padding: 0 10px">                                 array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'key' => 'bar',
-                               'compare' => 'NOT EXISTS',
-                       ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'key' => 'foo',
+                                       'compare' => 'NOT EXISTS',
+                               ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'key' => 'baz',
-                               'compare' => 'NOT EXISTS',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'key' => 'bar',
+                                       'compare' => 'NOT EXISTS',
+                               ),
+                               array(
+                                       'key' => 'baz',
+                                       'compare' => 'NOT EXISTS',
+                               ),
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts = $query->get_posts();
-               $this->assertEquals( 0, count( $posts ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( 0, count( $query->posts ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 23033
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @group meta
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_meta_query_decimal_results() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_meta_query_decimal_results() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $post_1 = $this->factory->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $post_2 = $this->factory->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $post_3 = $this->factory->post->create();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -215,121 +627,149 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        array(
-                                               'key' => 'decimal_value',
-                                               'value' => '.300',
-                                               'compare' => '=',
-                                               'type' => 'DECIMAL(10,2)'
-                                       )
-                               ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'decimal_value',
+                                       'value' => '.300',
+                                       'compare' => '=',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_3 ), wp_list_pluck( $query->posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_3 ), $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        array(
-                                               'key' => 'decimal_value',
-                                               'value' => '0.35',
-                                               'compare' => '>',
-                                               'type' => 'DECIMAL(10,2)'
-                                       )
-                               ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'decimal_value',
+                                       'value' => '0.35',
+                                       'compare' => '>',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_4 ), wp_list_pluck( $query->posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_4 ), $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        array(
-                                               'key' => 'decimal_value',
-                                               'value' => '0.3',
-                                               'compare' => '>=',
-                                               'type' => 'DECIMAL(10,2)'
-                                       )
-                               ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'decimal_value',
+                                       'value' => '0.3',
+                                       'compare' => '>=',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_3, $post_4 ), wp_list_pluck( $query->posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_3, $post_4 ), $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        array(
-                                               'key' => 'decimal_value',
-                                               'value' => '0',
-                                               'compare' => '<',
-                                               'type' => 'DECIMAL(10,2)'
-                                       )
-                               ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'decimal_value',
+                                       'value' => '0',
+                                       'compare' => '<',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_1 ), wp_list_pluck( $query->posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_1 ), $query->posts, 'ID' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        array(
-                                               'key' => 'decimal_value',
-                                               'value' => '0.3',
-                                               'compare' => '<=',
-                                               'type' => 'DECIMAL(10,2)'
-                                       )
-                               ),
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'decimal_value',
+                                       'value' => '0.3',
+                                       'compare' => '<=',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_1, $post_2, $post_3 ), wp_list_pluck( $query->posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_1, $post_2, $post_3 ), $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        array(
-                                               'key' => 'decimal_value',
-                                               'value' => array( 0.23409845, .31 ),
-                                               'compare' => 'BETWEEN',
-                                               'type' => 'DECIMAL(10, 10)'
-                                       )
-                               ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'decimal_value',
+                                       'value' => array( 0.23409845, .31 ),
+                                       'compare' => 'BETWEEN',
+                                       'type' => 'DECIMAL(10, 10)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_3 ), wp_list_pluck( $query->posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_3 ), $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        array(
-                                               'key' => 'decimal_value',
-                                               'value' => array( 0.23409845, .31 ),
-                                               'compare' => 'NOT BETWEEN',
-                                               'type' => 'DECIMAL(10,10)'
-                                       )
-                               ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'decimal_value',
+                                       'value' => array( 0.23409845, .31 ),
+                                       'compare' => 'NOT BETWEEN',
+                                       'type' => 'DECIMAL(10,10)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_1, $post_2, $post_4 ), wp_list_pluck( $query->posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_1, $post_2, $post_4 ), $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        array(
-                                               'key' => 'decimal_value',
-                                               'value' => '.3',
-                                               'compare' => 'LIKE',
-                                               'type' => 'DECIMAL(10,2)'
-                                       )
-                               ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'decimal_value',
+                                       'value' => '.3',
+                                       'compare' => 'LIKE',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_1, $post_3 ), wp_list_pluck( $query->posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_1, $post_3 ), $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        array(
-                                               'key' => 'decimal_value',
-                                               'value' => '.3',
-                                               'compare' => 'NOT LIKE',
-                                               'type' => 'DECIMAL(10,2)'
-                                       )
-                               ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         array(
+                                       'key' => 'decimal_value',
+                                       'value' => '.3',
+                                       'compare' => 'NOT LIKE',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_2, $post_4 ), wp_list_pluck( $query->posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_2, $post_4 ), $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query = new WP_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'orderby' => 'meta_value',
</span><span class="cx" style="display: block; padding: 0 10px">                        'order' => 'DESC',
</span><span class="cx" style="display: block; padding: 0 10px">                        'meta_key' => 'decimal_value',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'meta_type' => 'DECIMAL(10, 2)'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'meta_type' => 'DECIMAL(10, 2)',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEqualSets( array( $post_4, $post_3, $post_2, $post_1 ), wp_list_pluck( $query->posts, 'ID' ) );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $post_4, $post_3, $post_2, $post_1 ), $query->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -866,4 +1306,4 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNotContains( 'DESC', $q5->request );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNotContains( 'ASC', $q5->request );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre>
</div>
</div>

</body>
</html>