From a1355d0bb9ed502d10ed8d7d333544e7089ce34c Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 12 Jun 2013 19:53:43 +0200 Subject: [PATCH] Adding failing test for DDC-2214 Parameters being bound to an SQL query should have the same type as the identifier of the objects being bound to the placeholders of a DQL query - this is currently broken with proxies, as this test demonstrates. --- .../ORM/Functional/Ticket/DDC2214Test.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php new file mode 100644 index 000000000..060b6ba33 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php @@ -0,0 +1,71 @@ + + * + * @group DDC-2214 + */ +class DDC2214Test extends \Doctrine\Tests\OrmFunctionalTestCase +{ + protected function setUp() + { + parent::setUp(); + + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2214Foo'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2214Bar'), + )); + } + + public function testIssue() + { + $foo = new DDC2214Foo(); + $bar = new DDC2214Bar(); + + $foo->bar = $bar; + + $this->_em->persist($foo); + $this->_em->persist($bar); + $this->_em->flush(); + $this->_em->clear(); + + /* @var $foo \Doctrine\Tests\ORM\Functional\Ticket\DDC2214Foo */ + $foo = $this->_em->find(__NAMESPACE__ . '\\DDC2214Foo', $foo->id); + $bar = $foo->bar; + + $logger = $this->_em->getConnection()->getConfiguration()->getSQLLogger(); + + $related = $this + ->_em + ->createQuery('SELECT b FROM '.__NAMESPACE__ . '\DDC2214Bar b WHERE b.id IN(:ids)') + ->setParameter('ids', array($bar)) + ->getResult(); + + $query = end($logger->queries); + + $this->assertEquals(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY, $query['types'][0]); + } +} + +/** @Entity */ +class DDC2214Foo +{ + /** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */ + public $id; + + /** @ManyToOne(targetEntity="DDC2214Bar") */ + public $bar; +} + +/** @Entity */ +class DDC2214Bar +{ + /** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */ + public $id; +}