From 7e2f382e89448b7239b45f73f3b5be360435a0e6 Mon Sep 17 00:00:00 2001 From: Bingo-Soft Date: Sun, 13 Oct 2019 19:55:30 +0300 Subject: [PATCH] Improved SQL parts handling --- lib/Doctrine/DBAL/Query/QueryBuilder.php | 32 +++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index 46d7db7a21e..587e26656ab 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -52,23 +52,28 @@ class QueryBuilder */ private $connection; + /* + * The default values of SQL parts collection + */ + private const SQL_PARTS_DEFAULTS = [ + 'select' => [], + 'distinct' => false, + 'from' => [], + 'join' => [], + 'set' => [], + 'where' => null, + 'groupBy' => [], + 'having' => null, + 'orderBy' => [], + 'values' => [], + ]; + /** * The array of SQL parts collected. * * @var mixed[] */ - private $sqlParts = [ - 'select' => [], - 'distinct' => false, - 'from' => [], - 'join' => [], - 'set' => [], - 'where' => null, - 'groupBy' => [], - 'having' => null, - 'orderBy' => [], - 'values' => [], - ]; + private $sqlParts = self::SQL_PARTS_DEFAULTS; /** * The complete SQL string for this query. @@ -1103,8 +1108,7 @@ public function resetQueryParts($queryPartNames = null) */ public function resetQueryPart($queryPartName) { - $this->sqlParts[$queryPartName] = is_array($this->sqlParts[$queryPartName]) - ? [] : null; + $this->sqlParts[$queryPartName] = self::SQL_PARTS_DEFAULTS[$queryPartName]; $this->state = self::STATE_DIRTY;