Skip to content

Commit 55ef7f8

Browse files
authored
Merge pull request #6179 from morozov/deprecate-query-parts
Deprecate getting query parts from QueryBuilder
2 parents d3954ec + 2ec9b03 commit 55ef7f8

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

UPGRADE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ awareness about deprecated code.
66
- Use of our low-overhead runtime deprecation API, details:
77
https://github.com/doctrine/deprecations/
88

9+
# Upgrade to 3.8
10+
11+
## Deprecated getting query parts from `QueryBuilder`
12+
13+
The usage of `QueryBuilder::getQueryPart()` and `::getQueryParts()` is deprecated. The query parts
14+
are implementation details and should not be relied upon.
15+
916
# Upgrade to 3.6
1017

1118
## Deprecated not setting a schema manager factory

psalm.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,11 @@
499499
-->
500500
<referencedMethod name="Doctrine\DBAL\Connection::getEventManager"/>
501501
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::setEventManager"/>
502+
<!--
503+
TODO: remove in 4.0.0
504+
-->
505+
<referencedMethod name="Doctrine\DBAL\Query\QueryBuilder::getQueryPart"/>
506+
<referencedMethod name="Doctrine\DBAL\Query\QueryBuilder::getQueryParts"/>
502507

503508
<!-- TODO for PHPUnit 10 -->
504509
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::withConsecutive"/>

src/Query/QueryBuilder.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,22 +1297,38 @@ public function addOrderBy($sort, $order = null)
12971297
/**
12981298
* Gets a query part by its name.
12991299
*
1300+
* @deprecated The query parts are implementation details and should not be relied upon.
1301+
*
13001302
* @param string $queryPartName
13011303
*
13021304
* @return mixed
13031305
*/
13041306
public function getQueryPart($queryPartName)
13051307
{
1308+
Deprecation::triggerIfCalledFromOutside(
1309+
'doctrine/dbal',
1310+
'https://github.com/doctrine/dbal/pull/6179',
1311+
'Getting query parts is deprecated as they are implementation details.',
1312+
);
1313+
13061314
return $this->sqlParts[$queryPartName];
13071315
}
13081316

13091317
/**
13101318
* Gets all query parts.
13111319
*
1320+
* @deprecated The query parts are implementation details and should not be relied upon.
1321+
*
13121322
* @return mixed[]
13131323
*/
13141324
public function getQueryParts()
13151325
{
1326+
Deprecation::trigger(
1327+
'doctrine/dbal',
1328+
'https://github.com/doctrine/dbal/pull/6179',
1329+
'Getting query parts is deprecated as they are implementation details.',
1330+
);
1331+
13161332
return $this->sqlParts;
13171333
}
13181334

tests/Query/QueryBuilderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
use Doctrine\DBAL\Result;
1313
use Doctrine\DBAL\Types\Type;
1414
use Doctrine\DBAL\Types\Types;
15+
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
1516
use PHPUnit\Framework\MockObject\MockObject;
1617
use PHPUnit\Framework\TestCase;
1718

1819
use function hex2bin;
1920

2021
class QueryBuilderTest extends TestCase
2122
{
23+
use VerifyDeprecations;
24+
2225
/** @var Connection&MockObject */
2326
protected Connection $conn;
2427

@@ -792,6 +795,8 @@ public function testClone(): void
792795

793796
$qb->andWhere('u.id = 1');
794797

798+
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/6179');
799+
795800
self::assertNotSame($qb->getQueryParts(), $qbClone->getQueryParts());
796801
self::assertNotSame($qb->getParameters(), $qbClone->getParameters());
797802
}

0 commit comments

Comments
 (0)