summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin McCorkell <robin@mccorkell.me.uk>2016-03-11 17:22:29 +0000
committerMorris Jobke <hey@morrisjobke.de>2016-03-15 13:02:19 +0100
commit1b2f1cc2720682b253891a03c05e225cc7ca8882 (patch)
tree09b3e850046b6c47e40f97e3ba7074ee228731c0 /tests
parentad9a0804f3a40123ce931f6f7f365758fe8a0933 (diff)
downloadnextcloud-server-1b2f1cc2720682b253891a03c05e225cc7ca8882.tar.gz
nextcloud-server-1b2f1cc2720682b253891a03c05e225cc7ca8882.zip
Prevent certain DBs throwing exceptions on same-value updates
A PreconditionNotMetException must only be thrown if explicit preconditions are specified for setValues(), not if the value is merely the same as was already in the DB.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/db/connection.php30
1 files changed, 24 insertions, 6 deletions
diff --git a/tests/lib/db/connection.php b/tests/lib/db/connection.php
index b10b1a322a9..62d0a77ca1f 100644
--- a/tests/lib/db/connection.php
+++ b/tests/lib/db/connection.php
@@ -47,6 +47,11 @@ class Connection extends \Test\TestCase {
$this->connection = \OC::$server->getDatabaseConnection();
}
+ public function tearDown() {
+ parent::tearDown();
+ $this->connection->dropTable('table');
+ }
+
/**
* @param string $table
*/
@@ -86,6 +91,7 @@ class Connection extends \Test\TestCase {
* @depends testTableExists
*/
public function testDropTable() {
+ $this->makeTestTable();
$this->assertTableExist('table');
$this->connection->dropTable('table');
$this->assertTableNotExist('table');
@@ -111,8 +117,6 @@ class Connection extends \Test\TestCase {
]);
$this->assertEquals('foo', $this->getTextValueByIntergerField(1));
-
- $this->connection->dropTable('table');
}
public function testSetValuesOverWrite() {
@@ -131,8 +135,6 @@ class Connection extends \Test\TestCase {
]);
$this->assertEquals('bar', $this->getTextValueByIntergerField(1));
-
- $this->connection->dropTable('table');
}
public function testSetValuesOverWritePrecondition() {
@@ -154,8 +156,6 @@ class Connection extends \Test\TestCase {
]);
$this->assertEquals('bar', $this->getTextValueByIntergerField(1));
-
- $this->connection->dropTable('table');
}
/**
@@ -179,4 +179,22 @@ class Connection extends \Test\TestCase {
'booleanfield' => false
]);
}
+
+ public function testSetValuesSameNoError() {
+ $this->makeTestTable();
+ $this->connection->setValues('table', [
+ 'integerfield' => 1
+ ], [
+ 'textfield' => 'foo',
+ 'clobfield' => 'not_null'
+ ]);
+
+ // this will result in 'no affected rows' on certain optimizing DBs
+ // ensure the PreConditionNotMetException isn't thrown
+ $this->connection->setValues('table', [
+ 'integerfield' => 1
+ ], [
+ 'textfield' => 'foo'
+ ]);
+ }
}