diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index a39dbe3783c2b394e8298760a4f77696f6e2079e..4b1c560c5caa2e502accc9967b02bb32f07d3a29 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -34,6 +34,7 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\Common\EventManager; use Doctrine\DBAL\Platforms\MySqlPlatform; +use Doctrine\DBAL\Exception\ConstraintViolationException; use OC\DB\QueryBuilder\QueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; @@ -284,7 +285,7 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection { }, array_merge($keys, $values)) ); return $insertQb->execute(); - } catch (\Doctrine\DBAL\Exception\ConstraintViolationException $e) { + } catch (ConstraintViolationException $e) { // value already exists, try update $updateQb = $this->getQueryBuilder(); $updateQb->update($table); diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php index b9c55c23339f36d36dcec8ce89a0f2f787ab4ea3..2a0cd70f83a686cf97fa2faf4881a809159a417e 100644 --- a/tests/lib/DB/ConnectionTest.php +++ b/tests/lib/DB/ConnectionTest.php @@ -124,8 +124,7 @@ class ConnectionTest extends \Test\TestCase { $this->connection->setValues('table', [ 'integerfield' => 1 ], [ - 'textfield' => 'foo', - 'clobfield' => 'not_null' + 'textfield' => 'foo' ]); $this->connection->setValues('table', [ diff --git a/tests/lib/DB/MDB2SchemaReaderTest.php b/tests/lib/DB/MDB2SchemaReaderTest.php index 22c0ba28569bb22f58b8aa3e2f6bb5052f8db98a..c740eb97f4ba7d34c1902a0b54b9d59f8def71f8 100644 --- a/tests/lib/DB/MDB2SchemaReaderTest.php +++ b/tests/lib/DB/MDB2SchemaReaderTest.php @@ -42,8 +42,8 @@ class MDB2SchemaReaderTest extends \Test\TestCase { $this->assertCount(8, $table->getColumns()); $this->assertEquals(4, $table->getColumn('integerfield')->getLength()); - $this->assertTrue($table->getColumn('integerfield')->getAutoincrement()); - $this->assertNull($table->getColumn('integerfield')->getDefault()); + $this->assertFalse($table->getColumn('integerfield')->getAutoincrement()); + $this->assertEquals(0, $table->getColumn('integerfield')->getDefault()); $this->assertTrue($table->getColumn('integerfield')->getNotnull()); $this->assertInstanceOf('Doctrine\DBAL\Types\IntegerType', $table->getColumn('integerfield')->getType()); @@ -58,7 +58,7 @@ class MDB2SchemaReaderTest extends \Test\TestCase { $this->assertNull($table->getColumn('clobfield')->getLength()); $this->assertFalse($table->getColumn('clobfield')->getAutoincrement()); $this->assertNull($table->getColumn('clobfield')->getDefault()); - $this->assertTrue($table->getColumn('clobfield')->getNotnull()); + $this->assertFalse($table->getColumn('clobfield')->getNotnull()); $this->assertInstanceOf('Doctrine\DBAL\Types\TextType', $table->getColumn('clobfield')->getType()); $this->assertNull($table->getColumn('booleanfield')->getLength()); diff --git a/tests/lib/DB/testschema.xml b/tests/lib/DB/testschema.xml index dfca920a0efeee6b4ba2e8d839cae67d69ab98b4..8e6dc1a1d600dfeaaef694ed1cb635ca967a29a5 100644 --- a/tests/lib/DB/testschema.xml +++ b/tests/lib/DB/testschema.xml @@ -17,7 +17,7 @@ <type>integer</type> <default>0</default> <notnull>true</notnull> - <autoincrement>1</autoincrement> + <primary>true</primary> <length>4</length> </field> <field> @@ -37,7 +37,6 @@ <field> <name>clobfield</name> <type>clob</type> - <notnull>true</notnull> </field> <field> <name>booleanfield</name>