Skip to content

Commit 123cde5

Browse files
committed
Added MySqlRandom Sort & invalidated collections upon adding custom sorts
1 parent c859774 commit 123cde5

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
### 1.8.8
4+
5+
* Fixed: Custom sorts now invalidate collections
6+
* Added: MySqlRandom Sort
7+
38
### 1.8.7
49

510
* Fixed: Added value inspection to determine type when unit testing and no column

src/Collections/Collection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ final public function replaceCustomSort(Sort $sort)
363363
final public function addCustomSort(Sort $sort)
364364
{
365365
$this->sorts[] = $sort;
366+
$this->invalidate();
366367
}
367368

368369
/**
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rhubarb\Stem\Repositories\MySql\Sorts;
4+
5+
use Rhubarb\Stem\Collections\Sort;
6+
use Rhubarb\Stem\Sql\ExpressesSqlInterface;
7+
8+
class MySqlRandom extends Sort implements ExpressesSqlInterface {
9+
public function getSqlExpression()
10+
{
11+
return 'RAND()';
12+
}
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Rhubarb\Stem\Tests\unit\Repositories\MySql\Sorts;
4+
5+
use Rhubarb\Crown\Tests\Fixtures\TestCases\RhubarbTestCase;
6+
use Rhubarb\Stem\Repositories\MySql\Sorts\MySqlRandom;
7+
8+
class MySqlRandomTest extends RhubarbTestCase
9+
{
10+
public function testCustomSortSQL()
11+
{
12+
$this->assertEquals('RAND()', (new MySqlRandom())->getSqlExpression());
13+
}
14+
}

0 commit comments

Comments
 (0)