-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
437 changed files
with
1,193 additions
and
608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace Flat3\Lodata\Drivers\SQL; | ||
|
||
use Flat3\Lodata\Drivers\SQLEntitySet; | ||
use Flat3\Lodata\Exception\Internal\NodeHandledException; | ||
use Flat3\Lodata\Expression\Event; | ||
use Flat3\Lodata\Expression\Event\Operator; | ||
use Flat3\Lodata\Expression\Node\Operator\Lambda; | ||
use Flat3\Lodata\NavigationBinding; | ||
use Flat3\Lodata\NavigationProperty; | ||
use Flat3\Lodata\ReferentialConstraint; | ||
|
||
trait SQLLambda | ||
{ | ||
public function sqlLambdaFilter(Event $event): ?bool | ||
{ | ||
switch (true) { | ||
case $event instanceof Operator: | ||
$operator = $event->getNode(); | ||
|
||
switch (true) { | ||
case $operator instanceof Lambda: | ||
list ($lambdaExpression) = $operator->getArguments(); | ||
|
||
/** @var NavigationProperty $navigationProperty */ | ||
$navigationProperty = $operator->getNavigationProperty()->getValue(); | ||
|
||
/** @var NavigationBinding $navigationBinding */ | ||
$navigationBinding = $this->getBindingByNavigationProperty($navigationProperty); | ||
|
||
/** @var SQLEntitySet $targetSet */ | ||
$targetSet = $navigationBinding->getTarget(); | ||
|
||
/** @var ReferentialConstraint[] $constraints */ | ||
$constraints = $navigationBinding->getPath()->getConstraints()->all(); | ||
|
||
$parser = $lambdaExpression->getParser(); | ||
|
||
while ($constraints) { | ||
$constraint = array_shift($constraints); | ||
|
||
$this->addWhere( | ||
sprintf('( %s = %s ( SELECT %s from %s WHERE', | ||
$this->propertyToField($constraint->getProperty()), | ||
$operator instanceof Lambda\Any ? 'ANY' : 'ALL', | ||
$targetSet->propertyToField($constraint->getReferencedProperty()), | ||
$targetSet->getTable(), | ||
) | ||
); | ||
|
||
$operatingTargetSet = clone $targetSet; | ||
|
||
$parser->pushEntitySet($operatingTargetSet); | ||
$lambdaExpression->compute(); | ||
$parser->popEntitySet(); | ||
|
||
$this->addWhere($operatingTargetSet->where); | ||
$this->parameters = array_merge($this->parameters, $operatingTargetSet->getParameters()); | ||
|
||
$this->addWhere(')'); | ||
|
||
if ($constraints) { | ||
$this->addWhere('OR '); | ||
} | ||
} | ||
|
||
throw new NodeHandledException(); | ||
} | ||
break; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Flat3\Lodata\Expression\Node\Literal; | ||
|
||
use Flat3\Lodata\Expression\Node\Literal; | ||
|
||
/** | ||
* Lambda Argument | ||
* @package Flat3\Lodata\Expression\Node\Literal | ||
*/ | ||
class LambdaVariable extends Literal | ||
{ | ||
} |
Oops, something went wrong.