1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Connection; |
8
|
|
|
use Doctrine\ORM\Annotation as ORM; |
9
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
10
|
|
|
use function end; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Verifies that the type of parameters being bound to an SQL query is the same |
14
|
|
|
* of the identifier of the entities used as parameters in the DQL query, even |
15
|
|
|
* if the bound objects are proxies. |
16
|
|
|
* |
17
|
|
|
* @group DDC-2214 |
18
|
|
|
*/ |
19
|
|
|
class DDC2214Test extends OrmFunctionalTestCase |
20
|
|
|
{ |
21
|
|
|
protected function setUp() : void |
22
|
|
|
{ |
23
|
|
|
parent::setUp(); |
24
|
|
|
|
25
|
|
|
$this->schemaTool->createSchema( |
26
|
|
|
[ |
27
|
|
|
$this->em->getClassMetadata(DDC2214Foo::class), |
28
|
|
|
$this->em->getClassMetadata(DDC2214Bar::class), |
29
|
|
|
] |
30
|
|
|
); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testIssue() : void |
34
|
|
|
{ |
35
|
|
|
$foo = new DDC2214Foo(); |
36
|
|
|
$bar = new DDC2214Bar(); |
37
|
|
|
|
38
|
|
|
$foo->bar = $bar; |
39
|
|
|
|
40
|
|
|
$this->em->persist($foo); |
41
|
|
|
$this->em->persist($bar); |
42
|
|
|
$this->em->flush(); |
43
|
|
|
$this->em->clear(); |
44
|
|
|
|
45
|
|
|
/** @var \Doctrine\Tests\ORM\Functional\Ticket\DDC2214Foo $foo */ |
46
|
|
|
$foo = $this->em->find(DDC2214Foo::class, $foo->id); |
47
|
|
|
$bar = $foo->bar; |
48
|
|
|
|
49
|
|
|
$logger = $this->em->getConnection()->getConfiguration()->getSQLLogger(); |
50
|
|
|
|
51
|
|
|
$related = $this |
|
|
|
|
52
|
|
|
->em |
53
|
|
|
->createQuery('SELECT b FROM ' . __NAMESPACE__ . '\DDC2214Bar b WHERE b.id IN(:ids)') |
54
|
|
|
->setParameter('ids', [$bar]) |
55
|
|
|
->getResult(); |
56
|
|
|
|
57
|
|
|
$query = end($logger->queries); |
|
|
|
|
58
|
|
|
|
59
|
|
|
self::assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** @ORM\Entity */ |
64
|
|
|
class DDC2214Foo |
65
|
|
|
{ |
66
|
|
|
/** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue(strategy="AUTO") */ |
67
|
|
|
public $id; |
68
|
|
|
|
69
|
|
|
/** @ORM\ManyToOne(targetEntity=DDC2214Bar::class) */ |
70
|
|
|
public $bar; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** @ORM\Entity */ |
74
|
|
|
class DDC2214Bar |
75
|
|
|
{ |
76
|
|
|
/** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue(strategy="AUTO") */ |
77
|
|
|
public $id; |
78
|
|
|
} |
79
|
|
|
|