N°8511 - Enhance DBObjectSet to be able to order by id

This commit is contained in:
odain
2025-08-18 14:37:48 +02:00
parent e6a0d95cba
commit d80e26791d
2 changed files with 33 additions and 13 deletions

View File

@@ -88,4 +88,24 @@ class DBSearchCommitTest extends ItopDataTestCase
static::assertEquals(0, $oSet->Count());
}
/**
* @covers N°8511 - Enhance DBObjectSet to be able to order by id
*/
public function testDbObjectSetFetchMethodWorksWithOptimizeColumnLoadOrderedById(){
$sUID=uniqid();
$oOrg1 = $this->CreateOrganization($sUID);
$oOrg2 = $this->CreateOrganization($sUID);
$oSearch = DBSearch::FromOQL("SELECT Organization WHERE name=\"$sUID\"", ['uuid' => $sUID]);
$oSet = new \DBObjectSet($oSearch, ['name' => true, 'id' => false ]);
$oSet->OptimizeColumnLoad(['Organization' => ['name']]);
static::assertEquals(2, $oSet->Count());
static::assertEquals($oOrg2->GetKey(), $oSet->Fetch()->GetKey());
$oSet = new \DBObjectSet($oSearch, ['name' => true, 'id' => true ]);
static::assertEquals(2, $oSet->Count());
static::assertEquals($oOrg1->GetKey(), $oSet->Fetch()->GetKey());
}
}