Author: adrive
Date: 2008-09-18 11:31:18 +0100 (Thu, 18 Sep 2008)
New Revision: 4970

Modified:
   branches/1.0/lib/Doctrine/Connection/UnitOfWork.php
   branches/1.0/lib/Doctrine/Sequence/Oracle.php
   branches/1.0/tests/Sequence/OracleTestCase.php
Log:
Fixed #1466: fixed Oracle's lastInsertId()

Modified: branches/1.0/lib/Doctrine/Connection/UnitOfWork.php
===================================================================
--- branches/1.0/lib/Doctrine/Connection/UnitOfWork.php 2008-09-15 19:54:48 UTC 
(rev 4969)
+++ branches/1.0/lib/Doctrine/Connection/UnitOfWork.php 2008-09-18 10:31:18 UTC 
(rev 4970)
@@ -590,8 +590,10 @@
 
         if (empty($seq) && count($identifier) == 1 && $identifier[0] == 
$table->getIdentifier() &&
             $table->getIdentifierType() != Doctrine::IDENTIFIER_NATURAL) {
-            if (strtolower($this->conn->getDriverName()) == 'pgsql') {
+            if (($driver = strtolower($this->conn->getDriverName())) == 
'pgsql') {
                 $seq = $table->getTableName() . '_' . $identifier[0];
+            } elseif ($driver == 'oracle') {
+                $seq = $table->getTableName();
             }
 
             $id = $this->conn->sequence->lastInsertId($seq);

Modified: branches/1.0/lib/Doctrine/Sequence/Oracle.php
===================================================================
--- branches/1.0/lib/Doctrine/Sequence/Oracle.php       2008-09-15 19:54:48 UTC 
(rev 4969)
+++ branches/1.0/lib/Doctrine/Sequence/Oracle.php       2008-09-18 10:31:18 UTC 
(rev 4970)
@@ -74,7 +74,7 @@
         $seqName = $table . (empty($field) ? '' : '_'.$field);
         $sequenceName =  
$this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName), 
true);
 
-        return $this->conn->fetchOne('SELECT ' . $sequenceName . '.currval');
+        return $this->conn->fetchOne('SELECT ' . $sequenceName . '.currval 
FROM DUAL');
     }
 
     /**
@@ -93,4 +93,4 @@
 
         return $this->conn->fetchOne($query);
     }
-}
\ No newline at end of file
+}

Modified: branches/1.0/tests/Sequence/OracleTestCase.php
===================================================================
--- branches/1.0/tests/Sequence/OracleTestCase.php      2008-09-15 19:54:48 UTC 
(rev 4969)
+++ branches/1.0/tests/Sequence/OracleTestCase.php      2008-09-18 10:31:18 UTC 
(rev 4970)
@@ -50,6 +50,6 @@
     {
         $this->sequence->lastInsertId('user');
         
-        $this->assertEqual($this->adapter->pop(), 'SELECT user_seq.currval');
+        $this->assertEqual($this->adapter->pop(), 'SELECT user_seq.currval 
FROM DUAL');
     }
 }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to