Skip to content

Commit 7e2f382

Browse files
committed
Improved SQL parts handling
1 parent ce6b7f9 commit 7e2f382

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

lib/Doctrine/DBAL/Query/QueryBuilder.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,28 @@ class QueryBuilder
5252
*/
5353
private $connection;
5454

55+
/*
56+
* The default values of SQL parts collection
57+
*/
58+
private const SQL_PARTS_DEFAULTS = [
59+
'select' => [],
60+
'distinct' => false,
61+
'from' => [],
62+
'join' => [],
63+
'set' => [],
64+
'where' => null,
65+
'groupBy' => [],
66+
'having' => null,
67+
'orderBy' => [],
68+
'values' => [],
69+
];
70+
5571
/**
5672
* The array of SQL parts collected.
5773
*
5874
* @var mixed[]
5975
*/
60-
private $sqlParts = [
61-
'select' => [],
62-
'distinct' => false,
63-
'from' => [],
64-
'join' => [],
65-
'set' => [],
66-
'where' => null,
67-
'groupBy' => [],
68-
'having' => null,
69-
'orderBy' => [],
70-
'values' => [],
71-
];
76+
private $sqlParts = self::SQL_PARTS_DEFAULTS;
7277

7378
/**
7479
* The complete SQL string for this query.
@@ -1103,8 +1108,7 @@ public function resetQueryParts($queryPartNames = null)
11031108
*/
11041109
public function resetQueryPart($queryPartName)
11051110
{
1106-
$this->sqlParts[$queryPartName] = is_array($this->sqlParts[$queryPartName])
1107-
? [] : null;
1111+
$this->sqlParts[$queryPartName] = self::SQL_PARTS_DEFAULTS[$queryPartName];
11081112

11091113
$this->state = self::STATE_DIRTY;
11101114

0 commit comments

Comments
 (0)