mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Nomalise boolean ORM filter in to 1/0
This commit is contained in:
parent
15c0621fb6
commit
906d426034
@ -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) {
|
||||||
|
@ -793,6 +793,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
Block a user