N°4031 - OQL Error when AttributeObjectKey is used in JOIN condition

This commit is contained in:
Eric
2021-06-02 14:45:03 +02:00
parent 7168860a0b
commit 71fcc6f026
2 changed files with 16 additions and 1 deletions

View File

@@ -55,7 +55,7 @@ class OQLClassTreeOptimizer
$sJoinedClass = $oJoin->GetOOQLClassNode()->GetNodeClass();
$sExtKeyAttCode = $oJoin->GetLeftField();
$oExtKeyAttDef = MetaModel::GetAttributeDef($oCurrentClassNode->GetNodeClass(), $sExtKeyAttCode);
if ($sJoinedClass == $oExtKeyAttDef->GetTargetClass()) {
if (($oExtKeyAttDef instanceof AttributeExternalKey) && ($sJoinedClass == $oExtKeyAttDef->GetTargetClass())) {
// The join is not used, remove from tree
$oCurrentClassNode->RemoveJoin($sLeftKey, $index);
}

View File

@@ -720,4 +720,19 @@ class DBSearchTest extends ItopDataTestCase
/** @var \DBObjectSearch $oNestedSearchInExpression */
self::assertEquals($bAllowAllData, $oNestedSearchInExpression->IsAllDataAllowed(), 'Nested DBSearch AllowData value');
}
/**
* BUG N°4031 check AttributeObjectKey used in JOIN condition
* @throws \ConfigException
* @throws \CoreException
* @throws \MissingQueryArgument
* @throws \OQLException
*/
public function testAttributeObjectKey()
{
$sQuery = "SELECT II FROM InlineImage AS II JOIN UserRequest AS UR ON II.item_id = UR.id WHERE II.item_class = 'UserRequest'";
$oSearch = \DBObjectSearch::FromOQL($sQuery);
$oSearch->MakeSelectQuery();
self::assertTrue(true);
}
}