Make WordPress Core


Ignore:
Timestamp:
10/16/2014 07:33:24 PM (10 years ago)
Author:
boonebgorges
Message:

Introduce nested query support to WP_Date_Query.

This enhancement makes it possible to filter post, comment, and other queries
by date in ways that are arbitrarily complex, using mixed AND and OR relations.

Includes unit tests for the new syntax. In a few places, the existing unit
tests were slightly too strict (such as when checking the exact syntax of a SQL
string); these existing tests have been narrowed.

Props boonebgorges.
Fixes #29822.

File:
1 edited

Legend:

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

    r29906 r29923  
    5656                    'month' => 6,
    5757                ),
     58                'column' => 'post_date',
     59                'compare' => '=',
     60                'relation' => 'AND',
    5861            ),
     62            'column' => 'post_date',
     63            'compare' => '=',
     64            'relation' => 'AND',
    5965        );
    6066
     
    7480        ) );
    7581
    76         // Note: WP_Date_Query does not reset indexes
    7782        $expected = array(
    78             2 => array(
     83            array(
    7984                'before' => array(
    8085                    'year' => 2008,
    8186                    'month' => 6,
    8287                ),
     88                'column' => 'post_date',
     89                'compare' => '=',
     90                'relation' => 'AND',
    8391            ),
     92            'column' => 'post_date',
     93            'compare' => '=',
     94            'relation' => 'AND',
    8495        );
    8596
    86         $this->assertSame( $expected, $q->queries );
     97        $this->assertEquals( $expected, $q->queries );
    8798    }
    8899
Note: See TracChangeset for help on using the changeset viewer.