From edf096eb57437521bbc40e49bcfc3fdbd747b501 Mon Sep 17 00:00:00 2001 From: David Abdemoulaie Date: Fri, 14 May 2010 14:21:46 -0500 Subject: [PATCH] [DDC-588] EntityManager::refresh uses fieldName instead of columnName --- lib/Doctrine/ORM/UnitOfWork.php | 2 +- .../ORM/Functional/Ticket/DDC588Test.php | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 6bf7d6691..948ee1be2 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1480,7 +1480,7 @@ class UnitOfWork implements PropertyChangedListener $class = $this->_em->getClassMetadata(get_class($entity)); if ($this->getEntityState($entity) == self::STATE_MANAGED) { $this->getEntityPersister($class->name)->refresh( - array_combine($class->getIdentifierColumnNames(), $this->_entityIdentifiers[$oid]), + array_combine($class->getIdentifierFieldNames(), $this->_entityIdentifiers[$oid]), $entity ); } else { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php new file mode 100644 index 000000000..3f899d786 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php @@ -0,0 +1,48 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC588Site'), + )); + } + + public function testIssue() + { + $site = new DDC588Site('Foo'); + + $this->_em->persist($site); + $this->_em->flush(); + // Following should not result in exception + $this->_em->refresh($site); + } +} + +/** + * @Entity + */ +class DDC588Site +{ + /** + * @Id + * @Column(type="integer", name="site_id") + * @GeneratedValue + */ + public $id; + + /** + * @Column(type="string", length=45) + */ + protected $name = null; + + public function __construct($name = '') + { + $this->name = $name; + } +}