From 5aeabcb445acf0f3ae3809ca07094d44d86f59b6 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 13 Nov 2011 15:36:48 +0100 Subject: [PATCH] DDC-1490 - Fix id generation of sequence and identity to cast values to int --- lib/Doctrine/ORM/Id/IdentityGenerator.php | 2 +- lib/Doctrine/ORM/Id/SequenceGenerator.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/Id/IdentityGenerator.php b/lib/Doctrine/ORM/Id/IdentityGenerator.php index 75da2733d..d244871f2 100644 --- a/lib/Doctrine/ORM/Id/IdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/IdentityGenerator.php @@ -46,7 +46,7 @@ class IdentityGenerator extends AbstractIdGenerator */ public function generate(EntityManager $em, $entity) { - return $em->getConnection()->lastInsertId($this->_seqName); + return (int)$em->getConnection()->lastInsertId($this->_seqName); } /** diff --git a/lib/Doctrine/ORM/Id/SequenceGenerator.php b/lib/Doctrine/ORM/Id/SequenceGenerator.php index dd7de60ba..b02331e6b 100644 --- a/lib/Doctrine/ORM/Id/SequenceGenerator.php +++ b/lib/Doctrine/ORM/Id/SequenceGenerator.php @@ -46,7 +46,7 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable $this->_sequenceName = $sequenceName; $this->_allocationSize = $allocationSize; } - + /** * Generates an ID for the given entity. * @@ -60,11 +60,11 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable // Allocate new values $conn = $em->getConnection(); $sql = $conn->getDatabasePlatform()->getSequenceNextValSQL($this->_sequenceName); - - $this->_nextValue = $conn->fetchColumn($sql); + + $this->_nextValue = (int)$conn->fetchColumn($sql); $this->_maxValue = $this->_nextValue + $this->_allocationSize; } - + return $this->_nextValue++; } @@ -99,7 +99,7 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable public function unserialize($serialized) { $array = unserialize($serialized); - + $this->_sequenceName = $array['sequenceName']; $this->_allocationSize = $array['allocationSize']; }