mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #7602 from dhensby/pulls/3.5/fix-filter-any-inner-join
FIX ManyMany link table joined with LEFT JOIN
This commit is contained in:
commit
13b02feed7
@ -726,7 +726,7 @@ class DataQuery {
|
|||||||
list($parentClass, $componentClass, $parentField, $componentField, $relationTable) = $component;
|
list($parentClass, $componentClass, $parentField, $componentField, $relationTable) = $component;
|
||||||
$parentBaseClass = ClassInfo::baseDataClass($parentClass);
|
$parentBaseClass = ClassInfo::baseDataClass($parentClass);
|
||||||
$componentBaseClass = ClassInfo::baseDataClass($componentClass);
|
$componentBaseClass = ClassInfo::baseDataClass($componentClass);
|
||||||
$this->query->addInnerJoin($relationTable,
|
$this->query->addLeftJoin($relationTable,
|
||||||
"\"$relationTable\".\"$parentField\" = \"$parentBaseClass\".\"ID\"");
|
"\"$relationTable\".\"$parentField\" = \"$parentBaseClass\".\"ID\"");
|
||||||
if (!$this->query->isJoinedTo($componentBaseClass)) {
|
if (!$this->query->isJoinedTo($componentBaseClass)) {
|
||||||
$this->query->addLeftJoin($componentBaseClass,
|
$this->query->addLeftJoin($componentBaseClass,
|
||||||
|
@ -774,6 +774,15 @@ class DataListTest extends SapphireTest {
|
|||||||
$this->assertEquals(1, $list->count());
|
$this->assertEquals(1, $list->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFilterAnyWithRelation() {
|
||||||
|
$list = DataObjectTest_Player::get();
|
||||||
|
$list = $list->filterAny(array(
|
||||||
|
'Teams.Title:StartsWith' => 'Team',
|
||||||
|
'ID:GreaterThan' => 0,
|
||||||
|
));
|
||||||
|
$this->assertCount(4, $list);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFilterAnyMultipleArray() {
|
public function testFilterAnyMultipleArray() {
|
||||||
$list = DataObjectTest_TeamComment::get();
|
$list = DataObjectTest_TeamComment::get();
|
||||||
$list = $list->filterAny(array('Name'=>'Bob', 'Comment'=>'This is a team comment by Bob'));
|
$list = $list->filterAny(array('Name'=>'Bob', 'Comment'=>'This is a team comment by Bob'));
|
||||||
|
Loading…
Reference in New Issue
Block a user