Skip to content
Permalink
Browse files

Ensure that the driver schema dialects use is connected.

Failing to connect the driver causes failures when identifiers are
quoted using cached schema objects.

Fixes #4031
  • Loading branch information...
markstory committed Jul 22, 2014
1 parent c09e2b9 commit da8d54c96df408631300402f1c37fb3b87f737e2
Showing with 16 additions and 0 deletions.
  1. +4 −0 src/Database/Schema/BaseSchema.php
  2. +12 −0 tests/TestCase/Database/Schema/MysqlSchemaTest.php
@@ -35,9 +35,13 @@ abstract class BaseSchema {
/**
* Constructor
*
* This constructor will connect the driver so that methods like columnSql() and others
* will fail when the driver has not been connected.
*
* @param \Cake\Database\Driver $driver The driver to use.
*/
public function __construct(Driver $driver) {
$driver->connect();
$this->_driver = $driver;
}
@@ -842,6 +842,18 @@ public function testTruncateSql() {
$this->assertEquals('TRUNCATE TABLE `articles`', $result[0]);
}
/**
* Test that constructing a schema dialect connects the driver.
*
* @return void
*/
public function testConstructConnectsDriver() {
$driver = $this->getMock('Cake\Database\Driver');
$driver->expects($this->once())
->method('connect');
$schema = new MysqlSchema($driver);
}
/**
* Get a schema instance with a mocked driver/pdo instances
*

0 comments on commit da8d54c

Please sign in to comment.
You can’t perform that action at this time.