N°1213 - Allow NOT IN SELECT in OQL syntax - support of UNION requests

This commit is contained in:
Eric
2019-12-03 11:44:33 +01:00
parent c0ae983faa
commit b415b1eeae
4 changed files with 416 additions and 387 deletions

View File

@@ -1946,20 +1946,24 @@ class NestedQueryExpression extends Expression
return '('.$this->m_oNestedQuery->ToOQL(false, null, false).')';
}
}
/*TODO*/
public function Browse(Closure $callback)
{
$callback($this);
}
/**/
public function ApplyParameters($aArgs)
{
$this->m_oNestedQuery->ApplyParameters($aArgs);
}
/**/
public function GetUnresolvedFields($sAlias, &$aUnresolved)
{
}
/**/
public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
{
@@ -1969,6 +1973,7 @@ class NestedQueryExpression extends Expression
$this->m_oNestedQuery->AddConditionExpression($oExpression);
return clone $this;
}
/*TODO*/
public function ListRequiredFields()
{
@@ -1979,6 +1984,7 @@ class NestedQueryExpression extends Expression
}
return $aRes;
}
/*TODO */
public function CollectUsedParents(&$aTable)
{

File diff suppressed because it is too large Load Diff

View File

@@ -128,10 +128,12 @@ expression_prio4(A) ::= expression_prio4(X) operator4(Y) expression_prio3(Z). {
list(A) ::= PAR_OPEN list_items(X) PAR_CLOSE. {
A = new ListOqlExpression(X);
}
//added for IN (SELECT..)
list(A) ::= PAR_OPEN query(X) PAR_CLOSE. {
A = new NestedQueryOqlExpression(X);
}
}
list(A) ::= PAR_OPEN union(X) PAR_CLOSE. {
A = new NestedQueryOqlExpression(X);
}
list_items(A) ::= expression_prio4(X). {
A = array(X);
@@ -322,4 +324,4 @@ class OQLParser extends OQLParserRaw
}
}
}
}

View File

@@ -69,6 +69,22 @@ class OQLTest extends ItopDataTestCase
array('SELECT toto WHERE id IN (SELECT titi AS ti JOIN toto AS to ON to.a=ti.b)'),
array('SELECT toto WHERE id IN (SELECT titi AS ti JOIN toto AS to ON to.a=ti.b WHERE to.a=1)'),
array('SELECT toto WHERE id NOT IN (SELECT titi)'),
array("SELECT User AS U JOIN Person AS P ON U.contactid = P.id
WHERE U.status='enabled' AND U.id NOT IN (
SELECT User AS U
JOIN Person AS P ON U.contactid=P.id
JOIN URP_UserOrg AS L ON L.userid = U.id
WHERE U.status='enabled' AND L.allowed_org_id = P.org_id
UNION SELECT User AS U
WHERE U.status='enabled' AND U.id NOT IN (
SELECT User AS U
JOIN URP_UserOrg AS L ON L.userid = U.id
WHERE U.status='enabled'
)
)"),
array("SELECT UserRequest AS Ur WHERE Ur.id NOT IN (SELECT UserRequest AS Ur JOIN lnkFunctionalCIToTicket AS lnk ON lnk.ticket_id = Ur.id)"),
array("SELECT Ticket AS T WHERE T. finalclass IN ('userrequest' , 'change') AND T.id NOT IN (SELECT UserRequest AS Ur JOIN lnkFunctionalCIToTicket AS lnk ON lnk.ticket_id = Ur.id UNION SELECT Change AS C JOIN lnkFunctionalCIToTicket AS lnk ON lnk.ticket_id = C.id)"),
array("SELECT PhysicalDevice WHERE status='production' AND id NOT IN (SELECT PhysicalDevice AS p JOIN lnkFunctionalCIToProviderContract AS l ON l.functionalci_id=p.id)"),
);
}