Skip to content

Commit

Permalink
Improved SQL parts handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bingo-soft committed Oct 13, 2019
1 parent ce6b7f9 commit 7e2f382
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions lib/Doctrine/DBAL/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 7e2f382

Please sign in to comment.