#6464 add test
This commit is contained in:
parent
633c8461c8
commit
55882ca7a6
89
tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php
Normal file
89
tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* @group GH-6464
|
||||
*/
|
||||
class GH6464Test extends OrmFunctionalTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->_schemaTool->createSchema(
|
||||
[
|
||||
$this->_em->getClassMetadata(GH6464Post::class),
|
||||
$this->_em->getClassMetadata(GH6464User::class),
|
||||
$this->_em->getClassMetadata(GH6464Author::class),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that SqlWalker generates valid SQL for an INNER JOIN to CTI table
|
||||
*
|
||||
* SqlWalker needs to generate nested INNER JOIN statements, otherwise there would be INNER JOIN
|
||||
* statements without an ON clause, which are valid on e.g. MySQL but rejected by PostgreSQL.
|
||||
*/
|
||||
public function testIssue()
|
||||
{
|
||||
|
||||
$qb = $this->_em->createQueryBuilder();
|
||||
|
||||
$query = $qb
|
||||
->select('p', 'a')
|
||||
->from(GH6464Post::class, 'p')
|
||||
->innerJoin(GH6464Author::class, 'a', 'WITH', 'p.authorId = a.id')
|
||||
->getQuery();
|
||||
|
||||
$this->assertNotRegExp(
|
||||
'/INNER JOIN \w+ \w+ INNER JOIN/',
|
||||
$query->getSQL(),
|
||||
'As of GH-6464, every INNER JOIN should have an ON clause, which is missing here'
|
||||
);
|
||||
|
||||
// Query shouldn't yield a result, yet it shouldn't crash (anymore)
|
||||
$this->assertEquals([], $query->getResult());
|
||||
}
|
||||
}
|
||||
|
||||
/** @Entity */
|
||||
class GH6464Post
|
||||
{
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
public $id;
|
||||
|
||||
/** @Column(type="integer") */
|
||||
public $authorId;
|
||||
|
||||
/** @Column(length=100) */
|
||||
public $title;
|
||||
|
||||
/** @Column(type="text") */
|
||||
public $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @InheritanceType("JOINED")
|
||||
* @DiscriminatorColumn(name="discr", type="string")
|
||||
* @DiscriminatorMap({"author" = "GH6464Author"})
|
||||
*/
|
||||
abstract class GH6464User
|
||||
{
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
public $id;
|
||||
}
|
||||
|
||||
/** @Entity */
|
||||
class GH6464Author extends GH6464User
|
||||
{
|
||||
/** @Column(length=50) */
|
||||
public $displayName;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user