Fixed failing test which was ignoring a required (not null) column (#26303)
* Fixed failing test which was ignoring a required (not null) column * restored test to original, catching DriverException which also catches ConstraintViolationException * catch ConstraintViolationException again * removed unnecessary field from this test * clobfield should be nullable * clobfield now is nullable * removed autoincrement since whenever this strategy is enabled, oracle would not throw constraint violation exceptions (needed for setValues), which mysql still does * this field does not auto increment anymore * mark integerfield as primary, since it is not getting marked as such through auto increment anymore, integerfield default always has been 0 instead of null Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
39afcbd49f
commit
2ccf544ad7
|
@ -34,6 +34,7 @@ use Doctrine\DBAL\Configuration;
|
||||||
use Doctrine\DBAL\Cache\QueryCacheProfile;
|
use Doctrine\DBAL\Cache\QueryCacheProfile;
|
||||||
use Doctrine\Common\EventManager;
|
use Doctrine\Common\EventManager;
|
||||||
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||||
|
use Doctrine\DBAL\Exception\ConstraintViolationException;
|
||||||
use OC\DB\QueryBuilder\QueryBuilder;
|
use OC\DB\QueryBuilder\QueryBuilder;
|
||||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
@ -284,7 +285,7 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
|
||||||
}, array_merge($keys, $values))
|
}, array_merge($keys, $values))
|
||||||
);
|
);
|
||||||
return $insertQb->execute();
|
return $insertQb->execute();
|
||||||
} catch (\Doctrine\DBAL\Exception\ConstraintViolationException $e) {
|
} catch (ConstraintViolationException $e) {
|
||||||
// value already exists, try update
|
// value already exists, try update
|
||||||
$updateQb = $this->getQueryBuilder();
|
$updateQb = $this->getQueryBuilder();
|
||||||
$updateQb->update($table);
|
$updateQb->update($table);
|
||||||
|
|
|
@ -124,8 +124,7 @@ class ConnectionTest extends \Test\TestCase {
|
||||||
$this->connection->setValues('table', [
|
$this->connection->setValues('table', [
|
||||||
'integerfield' => 1
|
'integerfield' => 1
|
||||||
], [
|
], [
|
||||||
'textfield' => 'foo',
|
'textfield' => 'foo'
|
||||||
'clobfield' => 'not_null'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->connection->setValues('table', [
|
$this->connection->setValues('table', [
|
||||||
|
|
|
@ -42,8 +42,8 @@ class MDB2SchemaReaderTest extends \Test\TestCase {
|
||||||
$this->assertCount(8, $table->getColumns());
|
$this->assertCount(8, $table->getColumns());
|
||||||
|
|
||||||
$this->assertEquals(4, $table->getColumn('integerfield')->getLength());
|
$this->assertEquals(4, $table->getColumn('integerfield')->getLength());
|
||||||
$this->assertTrue($table->getColumn('integerfield')->getAutoincrement());
|
$this->assertFalse($table->getColumn('integerfield')->getAutoincrement());
|
||||||
$this->assertNull($table->getColumn('integerfield')->getDefault());
|
$this->assertEquals(0, $table->getColumn('integerfield')->getDefault());
|
||||||
$this->assertTrue($table->getColumn('integerfield')->getNotnull());
|
$this->assertTrue($table->getColumn('integerfield')->getNotnull());
|
||||||
$this->assertInstanceOf('Doctrine\DBAL\Types\IntegerType', $table->getColumn('integerfield')->getType());
|
$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->assertNull($table->getColumn('clobfield')->getLength());
|
||||||
$this->assertFalse($table->getColumn('clobfield')->getAutoincrement());
|
$this->assertFalse($table->getColumn('clobfield')->getAutoincrement());
|
||||||
$this->assertNull($table->getColumn('clobfield')->getDefault());
|
$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->assertInstanceOf('Doctrine\DBAL\Types\TextType', $table->getColumn('clobfield')->getType());
|
||||||
|
|
||||||
$this->assertNull($table->getColumn('booleanfield')->getLength());
|
$this->assertNull($table->getColumn('booleanfield')->getLength());
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<type>integer</type>
|
<type>integer</type>
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
<notnull>true</notnull>
|
<notnull>true</notnull>
|
||||||
<autoincrement>1</autoincrement>
|
<primary>true</primary>
|
||||||
<length>4</length>
|
<length>4</length>
|
||||||
</field>
|
</field>
|
||||||
<field>
|
<field>
|
||||||
|
@ -37,7 +37,6 @@
|
||||||
<field>
|
<field>
|
||||||
<name>clobfield</name>
|
<name>clobfield</name>
|
||||||
<type>clob</type>
|
<type>clob</type>
|
||||||
<notnull>true</notnull>
|
|
||||||
</field>
|
</field>
|
||||||
<field>
|
<field>
|
||||||
<name>booleanfield</name>
|
<name>booleanfield</name>
|
||||||
|
|
Loading…
Reference in New Issue