BUG Fix postgres / PDO support

This commit is contained in:
Damian Mooyman 2017-11-17 12:35:55 +13:00
parent ef58799103
commit cbf9e40115
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
2 changed files with 5 additions and 5 deletions

View File

@ -163,7 +163,7 @@ class PDOConnector extends DBConnector
$connCollation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'connection_collation'); $connCollation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'connection_collation');
// Set charset if given and not null. Can explicitly set to empty string to omit // Set charset if given and not null. Can explicitly set to empty string to omit
if ($parameters['driver'] !== 'sqlsrv') { if (!in_array($parameters['driver'], ['sqlsrv', 'pgsql'])) {
$charset = isset($parameters['charset']) $charset = isset($parameters['charset'])
? $parameters['charset'] ? $parameters['charset']
: $connCharset; : $connCharset;

View File

@ -104,17 +104,17 @@ class PDODatabaseTest extends SapphireTest
$this->markTestSkipped('This test requires the current DB connector is PDO'); $this->markTestSkipped('This test requires the current DB connector is PDO');
} }
$query = new SQLUpdate('MySQLDatabaseTest_Data'); $query = new SQLUpdate('"MySQLDatabaseTest_Data"');
$query->setAssignments(array('Title' => 'New Title')); $query->setAssignments(array('"Title"' => 'New Title'));
// Test update which affects no rows // Test update which affects no rows
$query->setWhere(array('Title' => 'Bob')); $query->setWhere(array('"Title"' => 'Bob'));
$result = $query->execute(); $result = $query->execute();
$this->assertInstanceOf(PDOQuery::class, $result); $this->assertInstanceOf(PDOQuery::class, $result);
$this->assertEquals(0, DB::affected_rows()); $this->assertEquals(0, DB::affected_rows());
// Test update which affects some rows // Test update which affects some rows
$query->setWhere(array('Title' => 'First Item')); $query->setWhere(array('"Title"' => 'First Item'));
$result = $query->execute(); $result = $query->execute();
$this->assertInstanceOf(PDOQuery::class, $result); $this->assertInstanceOf(PDOQuery::class, $result);
$this->assertEquals(1, DB::affected_rows()); $this->assertEquals(1, DB::affected_rows());