Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: doctrine/doctrine2
...
head fork: Ocramius/doctrine2
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 113 additions and 0 deletions.
  1. +113 −0 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1806Test.php
View
113 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1806Test.php
@@ -0,0 +1,113 @@
+<?php
+
+namespace Doctrine\Tests\ORM\Functional\Ticket;
+
+/**
+ * @group DDC-1806
+ */
+class DDC1806Test extends \Doctrine\Tests\OrmFunctionalTestCase
+{
+ protected function setUp() {
+ parent::setUp();
+ $this->_schemaTool->createSchema(array(
+ $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1806A'),
+ $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1806B'),
+ ));
+ }
+
+ public function testIssue()
+ {
+ $a1 = new DDC1806A();
+ $b1 = new DDC1806B();
+ $b2 = new DDC1806B();
+ $b1->setName('wrong');
+ $b2->setName('correct');
+ $a1->setB($b2);
+
+ $this->_em->persist($a1);
+ $this->_em->persist($b1);
+ $this->_em->persist($b2);
+ $this->_em->flush();
+ $a1Identifier = $a1->getId();
+ $this->_em->clear();
+
+ $dql1 = "SELECT a FROM " . __NAMESPACE__ . "\\DDC1806A a WHERE a.id = :id";
+ $dql2 = "SELECT a, b FROM " . __NAMESPACE__ . "\\DDC1806A a LEFT JOIN a.b b WHERE a.id = :id";
+
+ $fetchedA1 = $this->_em->createQuery($dql1)->setParameter('id', $a1Identifier)->getOneOrNullResult()->getB()->getName();
+ $this->_em->clear();
+ $fetchedA2 = $this->_em->createQuery($dql2)->setParameter('id', $a1Identifier)->getOneOrNullResult()->getB()->getName();
+
+ $this->assertEquals($fetchedA1, $fetchedA2);
+ }
+}
+
+/**
+ * @Table(name="DDC1806A")
+ * @Entity
+ */
+class DDC1806A {
+
+ /**
+ * @var integer $id
+ *
+ * @Column(name="a_id", type="integer", nullable=false)
+ * @Id
+ * @GeneratedValue(strategy="IDENTITY")
+ */
+ private $id;
+
+ /**
+ * @ManyToOne(targetEntity="DDC1806B")
+ * @JoinColumn(name="id", referencedColumnName="id")
+ */
+ private $b;
+
+ public function getId() {
+ return $this->id;
+ }
+
+ public function setB($b) {
+ $this->b = $b;
+ }
+
+ public function getB() {
+ return $this->b;
+ }
+}
+
+
+/**
+ * @Table(name="DDC1806B")
+ * @Entity
+ */
+class DDC1806B {
+
+ /**
+ * @var integer $id
+ *
+ * @Column(name="id", type="integer", nullable=false)
+ * @Id
+ * @GeneratedValue(strategy="IDENTITY")
+ */
+ private $id;
+
+ /**
+ * @var string $name
+ *
+ * @Column(name="name", type="string", length=255, nullable=true)
+ */
+ private $name;
+
+ public function getId() {
+ return $this->id;
+ }
+
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ public function getName() {
+ return $this->name;
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.