Skip to content

Commit

Permalink
ENH: Add test for sorting by a custom field in DataQuery.
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Dec 12, 2021
1 parent 081959e commit 303c17d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/php/ORM/DataQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,21 @@ public function testSurrogateFieldSort()
);
}

public function testCustomFieldWithAliasSort()
{
$query = new DataQuery(DataQueryTest\ObjectE::class);
$query->selectField(sprintf(
'(case when "Title" = %s then 1 else 0 end)',
DB::get_conn()->quoteString('Second')
), 'CustomColumn');
$query->sort('CustomColumn', 'DESC', true);
$query->sort('SortOrder', 'ASC', false);
$this->assertEquals(
['Second', 'First', 'Last'],
$query->column('Title')
);
}

public function testComparisonClauseDateStartsWith()
{
DB::query("INSERT INTO \"DataQueryTest_F\" (\"MyDate\") VALUES ('1988-03-04 06:30')");
Expand Down

0 comments on commit 303c17d

Please sign in to comment.