Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with DBAL develop #8861

Merged
merged 1 commit into from
Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions docs/en/reference/dql-doctrine-query-language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -490,21 +490,21 @@ where you can generate an arbitrary join with the following syntax:
With an arbitrary join the result differs from the joins using a mapped property.
The result of an arbitrary join is an one dimensional array with a mix of the entity from the ``SELECT``
and the joined entity fitting to the filtering of the query. In case of the example with ``User``
and ``Blacklist``, it can look like this:
and ``Banlist``, it can look like this:

- User
- Blacklist
- Blacklist
- Banlist
- Banlist
- User
- Blacklist
- Banlist
- User
- Blacklist
- Blacklist
- Blacklist
- Banlist
- Banlist
- Banlist

In this form of join, the ``Blacklist`` entities found by the filtering in the ``WITH`` part are not fetched by an accessor
method on ``User``, but are already part of the result. In case the accessor method for Blacklists is invoked on a User instance,
it loads all the related ``Blacklist`` objects corresponding to this ``User``. This change of behaviour needs to be considered
In this form of join, the ``Banlist`` entities found by the filtering in the ``WITH`` part are not fetched by an accessor
method on ``User``, but are already part of the result. In case the accessor method for Banlists is invoked on a User instance,
it loads all the related ``Banlist`` objects corresponding to this ``User``. This change of behaviour needs to be considered
when the DQL is switched to an arbitrary join.

.. note::
Expand Down Expand Up @@ -1283,13 +1283,14 @@ creating a class which extends ``AbstractHydrator``:
<?php
namespace MyProject\Hydrators;

use Doctrine\DBAL\FetchMode;
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;

class CustomHydrator extends AbstractHydrator
{
protected function _hydrateAll()
{
return $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
return $this->_stmt->fetchAll(FetchMode::FETCH_ASSOC);
}
}

Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/query-builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ while the named placeholders start with a : followed by a string.
Calling ``setParameter()`` automatically infers which type you are setting as
value. This works for integers, arrays of strings/integers, DateTime instances
and for managed entities. If you want to set a type explicitly you can call
the third argument to ``setParameter()`` explicitly. It accepts either a PDO
type or a DBAL Type name for conversion.
the third argument to ``setParameter()`` explicitly. It accepts either a DBAL
Doctrine\DBAL\ParameterType::* or a DBAL Type name for conversion.

.. note::

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Query/ParameterTypeInferer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Types\Types;
use PDO;

use function current;
use function is_array;
Expand Down Expand Up @@ -60,6 +60,6 @@ public static function inferType($value)
: Connection::PARAM_STR_ARRAY;
}

return PDO::PARAM_STR;
return ParameterType::STRING;
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ public function getRootEntities()
*
* @param string|int $key The parameter position or name.
* @param mixed $value The parameter value.
* @param string|int|null $type PDO::PARAM_* or \Doctrine\DBAL\Types\Type::* constant
* @param string|int|null $type ParameterType::* or \Doctrine\DBAL\Types\Type::* constant
*
* @return static
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\ParameterType;
use PDO;

/**
Expand Down Expand Up @@ -45,7 +46,7 @@ public function query()
/**
* {@inheritdoc}
*/
public function quote($input, $type = PDO::PARAM_STR)
public function quote($input, $type = ParameterType::STRING)
{
}

Expand Down
15 changes: 6 additions & 9 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ class DDC1225Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1225TestEntity1::class),
$this->_em->getClassMetadata(DDC1225TestEntity2::class),
]
);
} catch (PDOException $e) {
}
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(DDC1225TestEntity1::class),
$this->_em->getClassMetadata(DDC1225TestEntity2::class),
]
);
}

public function testIssue(): void
Expand Down
9 changes: 3 additions & 6 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ class DDC1250Test extends OrmFunctionalTestCase
protected function setUp(): void
{
parent::setUp();
try {
$this->_schemaTool->createSchema(
[$this->_em->getClassMetadata(DDC1250ClientHistory::class)]
);
} catch (PDOException $e) {
}
$this->_schemaTool->createSchema(
[$this->_em->getClassMetadata(DDC1250ClientHistory::class)]
);
}

public function testIssue(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
use DateTime;
use DateTimeImmutable;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Query\ParameterTypeInferer;
use Doctrine\Tests\OrmTestCase;
use PDO;

class ParameterTypeInfererTest extends OrmTestCase
{
Expand All @@ -20,8 +20,8 @@ public function providerParameterTypeInferer(): array
{
return [
[1, Type::INTEGER],
['bar', PDO::PARAM_STR],
['1', PDO::PARAM_STR],
['bar', ParameterType::STRING],
['1', ParameterType::STRING],
[new DateTime(), Type::DATETIME],
[new DateTimeImmutable(), Type::DATETIME_IMMUTABLE],
[new DateInterval('P1D'), Type::DATEINTERVAL],
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Tests/ORM/Query/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use DateTimeImmutable;
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Internal\Hydration\IterableResult;
use Doctrine\ORM\Query\Parameter;
Expand All @@ -23,7 +24,6 @@
use Doctrine\Tests\Models\Generic\DateTimeModel;
use Doctrine\Tests\OrmTestCase;
use Generator;
use PDO;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

use function assert;
Expand Down Expand Up @@ -75,7 +75,7 @@ public function testSetParameters(): void
public function testFree(): void
{
$query = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1');
$query->setParameter(2, 84, PDO::PARAM_INT);
$query->setParameter(2, 84, ParameterType::INTEGER);

$query->free();

Expand All @@ -87,7 +87,7 @@ public function testClone(): void
$dql = 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1';

$query = $this->entityManager->createQuery($dql);
$query->setParameter(2, 84, PDO::PARAM_INT);
$query->setParameter(2, 84, ParameterType::INTEGER);
$query->setHint('foo', 'bar');

$cloned = clone $query;
Expand Down