-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge origin/2.20.x into 3.3.x (using imerge)
- Loading branch information
Showing
29 changed files
with
698 additions
and
138 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
Submodule _theme
deleted from
6f1bc8
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\ORM\Query\Exec; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Result; | ||
|
||
/** | ||
* SQL executor for a given, final, single SELECT SQL query | ||
* | ||
* @method string getSqlStatements() | ||
*/ | ||
class FinalizedSelectExecutor extends AbstractSqlExecutor | ||
{ | ||
public function __construct(string $sql) | ||
{ | ||
$this->sqlStatements = $sql; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function execute(Connection $conn, array $params, array $types): Result | ||
{ | ||
return $conn->executeQuery($this->getSqlStatements(), $params, $types, $this->queryCacheProfile); | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\ORM\Query\Exec; | ||
|
||
use Doctrine\ORM\Query; | ||
|
||
/** | ||
* PreparedExecutorFinalizer is a wrapper for the SQL finalization | ||
* phase that does nothing - it is constructed with the sql executor | ||
* already. | ||
*/ | ||
final class PreparedExecutorFinalizer implements SqlFinalizer | ||
{ | ||
private AbstractSqlExecutor $executor; | ||
|
||
public function __construct(AbstractSqlExecutor $exeutor) | ||
{ | ||
$this->executor = $exeutor; | ||
} | ||
|
||
public function createExecutor(Query $query): AbstractSqlExecutor | ||
{ | ||
return $this->executor; | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\ORM\Query\Exec; | ||
|
||
use Doctrine\DBAL\LockMode; | ||
use Doctrine\ORM\Query; | ||
use Doctrine\ORM\Query\QueryException; | ||
use Doctrine\ORM\Utility\LockSqlHelper; | ||
|
||
/** | ||
* SingleSelectSqlFinalizer finalizes a given SQL query by applying | ||
* the query's firstResult/maxResult values as well as extra read lock/write lock | ||
* statements, both through the platform-specific methods. | ||
* | ||
* The resulting, "finalized" SQL is passed to a FinalizedSelectExecutor. | ||
*/ | ||
class SingleSelectSqlFinalizer implements SqlFinalizer | ||
{ | ||
use LockSqlHelper; | ||
|
||
public function __construct(private string $sql) | ||
{ | ||
} | ||
|
||
/** | ||
* This method exists temporarily to support old SqlWalker interfaces. | ||
* | ||
* @internal | ||
* | ||
* @psalm-internal Doctrine\ORM | ||
*/ | ||
public function finalizeSql(Query $query): string | ||
{ | ||
$platform = $query->getEntityManager()->getConnection()->getDatabasePlatform(); | ||
|
||
$sql = $platform->modifyLimitQuery($this->sql, $query->getMaxResults(), $query->getFirstResult()); | ||
|
||
$lockMode = $query->getHint(Query::HINT_LOCK_MODE) ?: LockMode::NONE; | ||
|
||
if ($lockMode !== LockMode::NONE && $lockMode !== LockMode::OPTIMISTIC && $lockMode !== LockMode::PESSIMISTIC_READ && $lockMode !== LockMode::PESSIMISTIC_WRITE) { | ||
throw QueryException::invalidLockMode(); | ||
} | ||
|
||
if ($lockMode === LockMode::PESSIMISTIC_READ) { | ||
$sql .= ' ' . $this->getReadLockSQL($platform); | ||
} elseif ($lockMode === LockMode::PESSIMISTIC_WRITE) { | ||
$sql .= ' ' . $this->getWriteLockSQL($platform); | ||
} | ||
|
||
return $sql; | ||
} | ||
|
||
/** @return FinalizedSelectExecutor */ | ||
public function createExecutor(Query $query): AbstractSqlExecutor | ||
{ | ||
return new FinalizedSelectExecutor($this->finalizeSql($query)); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\ORM\Query\Exec; | ||
|
||
use Doctrine\ORM\Query; | ||
|
||
/** | ||
* SqlFinalizers are created by OutputWalkers that traversed the DQL AST. | ||
* The SqlFinalizer instance can be kept in the query cache and re-used | ||
* at a later time. | ||
* | ||
* Once the SqlFinalizer has been created or retrieved from the query cache, | ||
* it receives the Query object again in order to yield the AbstractSqlExecutor | ||
* that will then be used to execute the query. | ||
* | ||
* The SqlFinalizer may assume that the DQL that was used to build the AST | ||
* and run the OutputWalker (which created the SqlFinalizer) is equivalent to | ||
* the query that will be passed to the createExecutor() method. Potential differences | ||
* are the parameter values or firstResult/maxResult settings. | ||
*/ | ||
interface SqlFinalizer | ||
{ | ||
public function createExecutor(Query $query): AbstractSqlExecutor; | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\ORM\Query; | ||
|
||
use Doctrine\ORM\Query\Exec\SqlFinalizer; | ||
|
||
/** | ||
* Interface for output walkers | ||
* | ||
* Output walkers, like tree walkers, can traverse the DQL AST to perform | ||
* their purpose. | ||
* | ||
* The goal of an OutputWalker is to ultimately provide the SqlFinalizer | ||
* which produces the final, executable SQL statement in a "finalization" phase. | ||
* | ||
* It must be possible to use the same SqlFinalizer for Queries with different | ||
* firstResult/maxResult values. In other words, SQL produced by the | ||
* output walker should not depend on those values, and any SQL generation/modification | ||
* specific to them should happen in the finalizer's `\Doctrine\ORM\Query\Exec\SqlFinalizer::createExecutor()` | ||
* method instead. | ||
*/ | ||
interface OutputWalker | ||
{ | ||
public function getFinalizer(AST\DeleteStatement|AST\UpdateStatement|AST\SelectStatement $AST): SqlFinalizer; | ||
} |
Oops, something went wrong.