Permalink
Browse files

Issue DBAL-371

Forward the SQLSTATE error code to DBALException
  • Loading branch information...
1 parent 8c06b7c commit 8d707a532312ac77199627cddb2c600306a53d35 @mnapoli committed Oct 24, 2012
@@ -44,7 +44,7 @@ public static function driverExceptionDuringQuery(\Exception $driverEx, $sql, ar
}
$msg .= ":\n\n".$driverEx->getMessage();
- return new self($msg, 0, $driverEx);
+ return new self($msg, (int) $driverEx->getCode(), $driverEx);
}
public static function invalidWrapperClass($wrapperClass)
@@ -0,0 +1,36 @@
+<?php
+
+namespace Doctrine\Tests\DBAL\Functional\Ticket;
+
+use Doctrine\DBAL\DBALException;
+
+/**
+ * @group DBAL-371
+ */
+class DBAL371Test extends \Doctrine\Tests\DbalFunctionalTestCase
+{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ if ($this->_conn->getSchemaManager()->tablesExist('DBAL371')) {
+ $this->_conn->executeQuery('DELETE FROM DBAL371');
+ } else {
+ $table = new \Doctrine\DBAL\Schema\Table('DBAL371');
+ $table->addColumn('id', 'integer');
+ $table->setPrimaryKey(array('id'));
+
+ $this->_conn->getSchemaManager()->createTable($table);
+ }
+ }
+
+ public function testExceptionCode()
+ {
+ $this->setExpectedException('Doctrine\DBAL\DBALException', null, 23000);
+ $stmt = $this->_conn->prepare('INSERT INTO DBAL371 VALUES (1)');
+ $this->_conn->beginTransaction();
+ $stmt->execute();
+ $stmt->execute();
+ $this->_conn->rollback();
+ }
+}

0 comments on commit 8d707a5

Please sign in to comment.