Merge 906d426034
into d22960d3ea
This commit is contained in:
commit
60a559a5a8
|
@ -96,4 +96,8 @@ class DBBoolean extends DBField
|
||||||
}
|
}
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function RAW() {
|
||||||
|
return $this->prepValueForDB($this->getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ class ExactMatchFilter extends SearchFilter
|
||||||
{
|
{
|
||||||
$this->model = $query->applyRelation($this->relation);
|
$this->model = $query->applyRelation($this->relation);
|
||||||
$field = $this->getDbName();
|
$field = $this->getDbName();
|
||||||
$value = $this->getValue();
|
$value = $this->getDbFormattedValue();
|
||||||
|
|
||||||
// Null comparison check
|
// Null comparison check
|
||||||
if ($value === null) {
|
if ($value === null) {
|
||||||
|
@ -77,7 +77,7 @@ class ExactMatchFilter extends SearchFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
$clause = [$where => $value];
|
$clause = [$where => $value];
|
||||||
|
|
||||||
return $this->aggregate ?
|
return $this->aggregate ?
|
||||||
$this->applyAggregate($query, $clause) :
|
$this->applyAggregate($query, $clause) :
|
||||||
$query->where($clause);
|
$query->where($clause);
|
||||||
|
|
|
@ -801,6 +801,20 @@ class DataListTest extends SapphireTest
|
||||||
$this->assertEquals(0, $list->count());
|
$this->assertEquals(0, $list->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFilterByBoolean() {
|
||||||
|
$list = Player::get();
|
||||||
|
$list = $list->filter(['IsRetired' => false]);
|
||||||
|
$this->assertEquals(3, $list->count(), 'Some records have IsRetired set to false');
|
||||||
|
$allFalse = $list->column('IsRetired');
|
||||||
|
$this->assertNotContains(true, $allFalse, 'Filter false should filter all true values');
|
||||||
|
|
||||||
|
$list = Player::get();
|
||||||
|
$list = $list->filter(['IsRetired' => true]);
|
||||||
|
$this->assertEquals(1, $list->count(), 'One records has IsRetired set to true');
|
||||||
|
$allTrue = $list->column('IsRetired');
|
||||||
|
$this->assertNotContains(false, $allTrue, 'Filter true should filter all false values');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $list->filter(['Name'=>'bob, 'Age'=>21]); // bob with the age 21
|
* $list->filter(['Name'=>'bob, 'Age'=>21]); // bob with the age 21
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue