1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
4
|
|
|
|
5
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @group GH-6464 |
9
|
|
|
*/ |
10
|
|
|
class GH6464Test extends OrmFunctionalTestCase |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* {@inheritDoc} |
14
|
|
|
*/ |
15
|
|
|
protected function setUp() : void |
16
|
|
|
{ |
17
|
|
|
parent::setUp(); |
18
|
|
|
|
19
|
|
|
$this->_schemaTool->createSchema([ |
20
|
|
|
$this->_em->getClassMetadata(GH6464Post::class), |
21
|
|
|
$this->_em->getClassMetadata(GH6464User::class), |
22
|
|
|
$this->_em->getClassMetadata(GH6464Author::class), |
23
|
|
|
]); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Verifies that SqlWalker generates valid SQL for an INNER JOIN to CTI table |
28
|
|
|
* |
29
|
|
|
* SqlWalker needs to generate nested INNER JOIN statements, otherwise there would be INNER JOIN |
30
|
|
|
* statements without an ON clause, which are valid on e.g. MySQL but rejected by PostgreSQL. |
31
|
|
|
*/ |
32
|
|
|
public function testIssue() : void |
33
|
|
|
{ |
34
|
|
|
$query = $this->_em->createQueryBuilder() |
35
|
|
|
->select('p') |
36
|
|
|
->from(GH6464Post::class, 'p') |
37
|
|
|
->innerJoin(GH6464Author::class, 'a', 'WITH', 'p.authorId = a.id') |
38
|
|
|
->getQuery(); |
39
|
|
|
|
40
|
|
|
$this->assertNotRegExp( |
41
|
|
|
'/INNER JOIN \w+ \w+ INNER JOIN/', |
42
|
|
|
$query->getSQL(), |
|
|
|
|
43
|
|
|
'As of GH-6464, every INNER JOIN should have an ON clause, which is missing here' |
44
|
|
|
); |
45
|
|
|
|
46
|
|
|
// Query shouldn't yield a result, yet it shouldn't crash (anymore) |
47
|
|
|
$this->assertEquals([], $query->getResult()); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** @Entity */ |
52
|
|
|
class GH6464Post |
53
|
|
|
{ |
54
|
|
|
/** @Id @Column(type="integer") @GeneratedValue */ |
55
|
|
|
public $id; |
56
|
|
|
|
57
|
|
|
/** @Column(type="integer") */ |
58
|
|
|
public $authorId; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @Entity |
63
|
|
|
* @InheritanceType("JOINED") |
64
|
|
|
* @DiscriminatorColumn(name="discr", type="string") |
65
|
|
|
* @DiscriminatorMap({"author" = "GH6464Author"}) |
66
|
|
|
*/ |
67
|
|
|
abstract class GH6464User |
68
|
|
|
{ |
69
|
|
|
/** @Id @Column(type="integer") @GeneratedValue */ |
70
|
|
|
public $id; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** @Entity */ |
74
|
|
|
class GH6464Author extends GH6464User |
75
|
|
|
{ |
76
|
|
|
} |
77
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: