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 #7065

Merged
merged 1 commit into from
Feb 18, 2018
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
3 changes: 2 additions & 1 deletion docs/en/reference/dql-doctrine-query-language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1228,13 +1228,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::Associative);
}
}
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 @@ -244,8 +244,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.

If you've got several parameters to bind to your query, you can
also use setParameters() instead of setParameter() with the
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace Doctrine\ORM\Internal\Hydration;

use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\UnitOfWork;
use PDO;
use function array_merge;

/**
Expand Down Expand Up @@ -146,7 +146,7 @@ public function hydrateAll($stmt, $resultSetMapping, array $hints = [])
*/
public function hydrateRow()
{
$row = $this->stmt->fetch(PDO::FETCH_ASSOC);
$row = $this->stmt->fetch(FetchMode::ASSOCIATIVE);

if (! $row) {
$this->cleanup();
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Doctrine\ORM\Internal\Hydration;

use Doctrine\DBAL\FetchMode;
use Doctrine\ORM\Mapping\ToOneAssociationMetadata;
use PDO;
use function count;
use function end;
use function is_array;
Expand Down Expand Up @@ -72,7 +72,7 @@ protected function hydrateAllData()
{
$result = [];

while ($data = $this->stmt->fetch(PDO::FETCH_ASSOC)) {
while ($data = $this->stmt->fetch(FetchMode::ASSOCIATIVE)) {
$this->hydrateRowData($data, $result);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace Doctrine\ORM\Internal\Hydration;

use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\FetchMode;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ManyToManyAssociationMetadata;
use Doctrine\ORM\Mapping\ToManyAssociationMetadata;
use Doctrine\ORM\Mapping\ToOneAssociationMetadata;
use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Query;
use Doctrine\ORM\UnitOfWork;
use PDO;
use ProxyManager\Proxy\GhostObjectInterface;
use function array_fill_keys;
use function array_keys;
Expand Down Expand Up @@ -146,7 +146,7 @@ protected function hydrateAllData()
{
$result = [];

while ($row = $this->stmt->fetch(PDO::FETCH_ASSOC)) {
while ($row = $this->stmt->fetch(FetchMode::ASSOCIATIVE)) {
$this->hydrateRowData($row, $result);
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Doctrine\ORM\Internal\Hydration;

use Doctrine\DBAL\FetchMode;

/**
* Hydrator that produces flat, rectangular results of scalar data.
* The created result is almost the same as a regular SQL result set, except
Expand All @@ -18,7 +20,7 @@ protected function hydrateAllData()
{
$result = [];

while ($data = $this->stmt->fetch(\PDO::FETCH_ASSOC)) {
while ($data = $this->stmt->fetch(FetchMode::ASSOCIATIVE)) {
$this->hydrateRowData($data, $result);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Doctrine\ORM\Internal\Hydration;

use Doctrine\DBAL\FetchMode;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\Query;
use PDO;
use function array_keys;
use function array_search;
use function count;
Expand Down Expand Up @@ -56,7 +56,7 @@ protected function hydrateAllData()
{
$result = [];

while ($row = $this->stmt->fetch(PDO::FETCH_ASSOC)) {
while ($row = $this->stmt->fetch(FetchMode::ASSOCIATIVE)) {
$this->hydrateRowData($row, $result);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\ORM\Internal\Hydration;

use Doctrine\DBAL\FetchMode;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use function array_shift;
Expand All @@ -20,7 +21,7 @@ class SingleScalarHydrator extends AbstractHydrator
*/
protected function hydrateAllData()
{
$data = $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
$data = $this->stmt->fetchAll(FetchMode::ASSOCIATIVE);
$numRows = count($data);

if ($numRows === 0) {
Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\ORM\Query\AST\Functions;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\TrimMode;
use Doctrine\ORM\Query\AST\Node;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
Expand Down Expand Up @@ -89,18 +89,18 @@ public function parse(Parser $parser)
private function getTrimMode()
{
if ($this->leading) {
return AbstractPlatform::TRIM_LEADING;
return TrimMode::LEADING;
}

if ($this->trailing) {
return AbstractPlatform::TRIM_TRAILING;
return TrimMode::TRAILING;
}

if ($this->both) {
return AbstractPlatform::TRIM_BOTH;
return TrimMode::BOTH;
}

return AbstractPlatform::TRIM_UNSPECIFIED;
return TrimMode::UNSPECIFIED;
}

private function parseTrimMode(Parser $parser)
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Query/ParameterTypeInferer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\ORM\Query;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Types\Type;
use function current;
use function is_array;
Expand Down Expand Up @@ -49,6 +50,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 @@ -522,7 +522,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 self
*/
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 @@ -5,6 +5,7 @@
namespace Doctrine\Tests\Mocks;

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

/**
* Mock class for DriverConnection.
Expand Down Expand Up @@ -51,7 +52,7 @@ public function query()
/**
* {@inheritdoc}
*/
public function quote($input, $type=\PDO::PARAM_STR)
public function quote($input, $type = ParameterType::STRING)
{
}

Expand Down
12 changes: 5 additions & 7 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\DBAL\DBALException;
use Doctrine\ORM\Annotation as ORM;

/**
Expand All @@ -14,15 +15,12 @@ class DDC1225Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function setUp()
{
parent::setUp();
try {
$this->schemaTool->createSchema(
[
$this->schemaTool->createSchema(
[
$this->em->getClassMetadata(DDC1225_TestEntity1::class),
$this->em->getClassMetadata(DDC1225_TestEntity2::class),
]
);
} catch (\PDOException $e) {
}
]
);
}

public function testIssue()
Expand Down
11 changes: 4 additions & 7 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ class DDC1250Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function setUp()
{
parent::setUp();
try {
$this->schemaTool->createSchema(
[
$this->schemaTool->createSchema(
[
$this->em->getClassMetadata(DDC1250ClientHistory::class),
]
);
} catch (\PDOException $e) {
}
]
);
}

public function testIssue()
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Doctrine\Tests\ORM\Hydration;

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

class CustomHydratorTest extends HydrationTestCase
{
Expand All @@ -25,6 +25,6 @@ class CustomHydrator extends AbstractHydrator
{
protected function hydrateAllData()
{
return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
return $this->stmt->fetchAll(FetchMode::ASSOCIATIVE);
}
}
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 @@ -4,20 +4,20 @@

namespace Doctrine\Tests\ORM\Query;

use Doctrine\DBAL\ParameterType;
use Doctrine\ORM\Query\ParameterTypeInferer;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\OrmTestCase;
use PDO;

class ParameterTypeInfererTest extends OrmTestCase
{
public function providerParameterTypeInferer()
{
$data = [
[1, Type::INTEGER],
["bar", PDO::PARAM_STR],
["1", PDO::PARAM_STR],
["bar", ParameterType::STRING],
["1", ParameterType::STRING],
[new \DateTime, Type::DATETIME],
[new \DateInterval('P1D'), Type::DATEINTERVAL],
[[2], Connection::PARAM_INT_ARRAY],
Expand Down
5 changes: 3 additions & 2 deletions tests/Doctrine/Tests/ORM/Query/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\DBAL\ParameterType;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Internal\Hydration\IterableResult;
use Doctrine\ORM\Query\Parameter;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function testSetParameters()
public function testFree()
{
$query = $this->em->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 @@ -74,7 +75,7 @@ public function testClone()
$dql = "select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1";

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

$cloned = clone $query;
Expand Down