1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
4
|
|
|
|
5
|
|
|
class DDC726Test extends \Doctrine\Tests\OrmFunctionalTestCase |
6
|
|
|
{ |
7
|
|
|
protected function setUp() |
8
|
|
|
{ |
9
|
|
|
parent::setUp(); |
10
|
|
|
$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); |
11
|
|
|
$this->_schemaTool->createSchema( |
12
|
|
|
[ |
13
|
|
|
$this->_em->getClassMetadata(DDC726Group::class), |
14
|
|
|
] |
15
|
|
|
); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testWhereInWithCompositeIdentifiers() |
19
|
|
|
{ |
20
|
|
|
$sql = <<<SQL |
21
|
|
|
SELECT a FROM groups a |
22
|
|
|
INNER JOIN groups_foo b ON b.id = a.foo |
23
|
|
|
INNER JOIN groups_bar c ON c.id = a.bar |
24
|
|
|
WHERE (b.id, c.id) IN ( |
25
|
|
|
SELECT a2.foo, a2.bar |
26
|
|
|
FROM groups a2 |
27
|
|
|
WHERE a2.name = 'foo' |
28
|
|
|
) |
29
|
|
|
SQL; |
30
|
|
|
$in = $this->_em->createQueryBuilder(); |
31
|
|
|
$in->select('IDENTITY(d) FROM Doctrine\Tests\ORM\Functional\Ticket\DDC726Group d WHERE d.name = "foo"'); |
32
|
|
|
|
33
|
|
|
$qb = $this->_em->createQueryBuilder(); |
34
|
|
|
$qb->select('a') |
35
|
|
|
->from(DDC726Group::class, 'a') |
36
|
|
|
->innerJoin('a.foo', 'b') |
37
|
|
|
->innerJoin('a.bar', 'c') |
38
|
|
|
->where($qb->expr()->in('(b.id, c.id)', $in->getDQL())); |
39
|
|
|
|
40
|
|
|
$this->assertEquals($qb->getQuery()->getSQL(), $sql); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @Entity |
46
|
|
|
* @Table(name="groups_foo") |
47
|
|
|
*/ |
48
|
|
|
class DDC726GroupFoo { |
49
|
|
|
/** |
50
|
|
|
* @Id @GeneratedValue |
51
|
|
|
* @Column(type="integer") |
52
|
|
|
*/ |
53
|
|
|
private $id; |
54
|
|
|
|
55
|
|
|
public function getId() { return $this->id; } |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @Entity |
60
|
|
|
* @Table(name="groups_bar") |
61
|
|
|
*/ |
62
|
|
|
class DDC726GroupBar { |
63
|
|
|
/** |
64
|
|
|
* @Id @GeneratedValue |
65
|
|
|
* @Column(type="integer") |
66
|
|
|
*/ |
67
|
|
|
private $id; |
68
|
|
|
|
69
|
|
|
public function getId() { return $this->id; } |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @Entity |
74
|
|
|
* @Table(name="groups") |
75
|
|
|
*/ |
76
|
|
|
class DDC726Group { |
77
|
|
|
/** @Column(type="string", nullable=false) */ |
78
|
|
|
private $name; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @Id |
82
|
|
|
* @ManyToOne(targetEntity="DDC726GroupFoo", inversedBy="foo") |
83
|
|
|
* @JoinColumn(name="foo_id", referencedColumnName="id", nullable=false) |
84
|
|
|
*/ |
85
|
|
|
private $foo; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @Id |
89
|
|
|
* @ManyToOne(targetEntity="DDC726GroupBar", inversedBy="bar") |
90
|
|
|
* @JoinColumn(name="bar_id", referencedColumnName="id", nullable=false) |
91
|
|
|
*/ |
92
|
|
|
private $bar; |
93
|
|
|
|
94
|
|
|
public function getName() { return $this->name; } |
95
|
|
|
|
96
|
|
|
public function setName($name) { $this->name = $name; } |
97
|
|
|
|
98
|
|
|
public function getFoo() { return $this->foo; } |
99
|
|
|
|
100
|
|
|
public function setFoo(DDC726GroupFoo $foo) { $this->foo = $foo; } |
101
|
|
|
|
102
|
|
|
public function getBar() { return $this->bar; } |
103
|
|
|
|
104
|
|
|
public function setBar(DDC726GroupBar $bar) { $this->bar = $bar; } |
105
|
|
|
} |
106
|
|
|
|