Commit 6a3aa849 authored by romanb's avatar romanb

[2.0] Made MySqlPlatform default to innodb table engine. Some cleanups while...

[2.0] Made MySqlPlatform default to innodb table engine. Some cleanups while investigating the optimistic locking failures.
parent 59fff29c
...@@ -1456,7 +1456,8 @@ abstract class AbstractPlatform ...@@ -1456,7 +1456,8 @@ abstract class AbstractPlatform
* the format of a stored datetime value of this platform. * the format of a stored datetime value of this platform.
* *
* @return string The format string. * @return string The format string.
* TODO: We need to get the specific format for each dbms and override this *
* @todo We need to get the specific format for each dbms and override this
* function for each platform * function for each platform
*/ */
public function getDateTimeFormatString() public function getDateTimeFormatString()
......
...@@ -25,7 +25,8 @@ use Doctrine\Common\DoctrineException; ...@@ -25,7 +25,8 @@ use Doctrine\Common\DoctrineException;
/** /**
* The MySqlPlatform provides the behavior, features and SQL dialect of the * The MySqlPlatform provides the behavior, features and SQL dialect of the
* MySQL database platform. * MySQL database platform. This platform represents a MySQL 5.0 or greater platform that
* uses the InnoDB storage engine.
* *
* @since 2.0 * @since 2.0
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
...@@ -472,15 +473,12 @@ class MySqlPlatform extends AbstractPlatform ...@@ -472,15 +473,12 @@ class MySqlPlatform extends AbstractPlatform
} }
} }
$type = false;
// get the type of the table // get the type of the table
if (isset($options['type'])) { if (isset($options['engine'])) {
$type = $options['type']; $optionStrings[] = 'ENGINE = ' . $engine;
} } else {
// default to innodb
if ($type) { $optionStrings[] = 'ENGINE = InnoDB';
$optionStrings[] = 'ENGINE = ' . $type;
} }
if ( ! empty($optionStrings)) { if ( ! empty($optionStrings)) {
......
...@@ -756,4 +756,15 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -756,4 +756,15 @@ class PostgreSqlPlatform extends AbstractPlatform
{ {
return strtolower($column); return strtolower($column);
} }
/**
* Gets the format string, as accepted by the date() function, that describes
* the format of a stored datetime value of this platform.
*
* @return string The format string.
*/
/*public function getDateTimeFormatString()
{
return 'Y-m-d H:i:s.u';
}*/
} }
\ No newline at end of file
...@@ -37,7 +37,7 @@ class MySqlPlatformTest extends \Doctrine\Tests\DbalTestCase ...@@ -37,7 +37,7 @@ class MySqlPlatformTest extends \Doctrine\Tests\DbalTestCase
); );
$sql = $this->_platform->getCreateTableSql('test', $columns, $options); $sql = $this->_platform->getCreateTableSql('test', $columns, $options);
$this->assertEquals('CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) NOT NULL, PRIMARY KEY(id))', $sql[0]); $this->assertEquals('CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB', $sql[0]);
} }
public function testGeneratesTableAlterationSql() public function testGeneratesTableAlterationSql()
......
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
namespace Doctrine\Tests\ORM\Functional\Locking; namespace Doctrine\Tests\ORM\Functional\Locking;
use Doctrine\Tests\Mocks\MetadataDriverMock;
use Doctrine\Tests\Mocks\DatabasePlatformMock;
use Doctrine\Tests\Mocks\EntityManagerMock;
use Doctrine\Tests\Mocks\ConnectionMock;
use Doctrine\Tests\Mocks\DriverMock;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Common\EventManager; use Doctrine\Common\EventManager;
use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\ClassMetadataFactory;
......
...@@ -27,10 +27,10 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -27,10 +27,10 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
$tool = new SchemaTool($this->_em); $tool = new SchemaTool($this->_em);
$sql = $tool->getCreateSchemaSql($classes); $sql = $tool->getCreateSchemaSql($classes);
$this->assertEquals(count($sql), 8); $this->assertEquals(count($sql), 8);
$this->assertEquals("CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(id))", $sql[0]); $this->assertEquals("CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]);
$this->assertEquals("CREATE TABLE cms_users_groups (user_id INT DEFAULT NULL, group_id INT DEFAULT NULL, PRIMARY KEY(user_id, group_id))", $sql[1]); $this->assertEquals("CREATE TABLE cms_users_groups (user_id INT DEFAULT NULL, group_id INT DEFAULT NULL, PRIMARY KEY(user_id, group_id)) ENGINE = InnoDB", $sql[1]);
$this->assertEquals("CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, status VARCHAR(50) NOT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))", $sql[2]); $this->assertEquals("CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, status VARCHAR(50) NOT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[2]);
$this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber))", $sql[3]); $this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber)) ENGINE = InnoDB", $sql[3]);
$this->assertEquals("ALTER TABLE cms_addresses ADD FOREIGN KEY (user_id) REFERENCES cms_users(id)", $sql[4]); $this->assertEquals("ALTER TABLE cms_addresses ADD FOREIGN KEY (user_id) REFERENCES cms_users(id)", $sql[4]);
$this->assertEquals("ALTER TABLE cms_users_groups ADD FOREIGN KEY (user_id) REFERENCES cms_users(id)", $sql[5]); $this->assertEquals("ALTER TABLE cms_users_groups ADD FOREIGN KEY (user_id) REFERENCES cms_users(id)", $sql[5]);
$this->assertEquals("ALTER TABLE cms_users_groups ADD FOREIGN KEY (group_id) REFERENCES cms_groups(id)", $sql[6]); $this->assertEquals("ALTER TABLE cms_users_groups ADD FOREIGN KEY (group_id) REFERENCES cms_groups(id)", $sql[6]);
...@@ -78,7 +78,7 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -78,7 +78,7 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
$sql = $tool->getUpdateSchemaSql($classes); $sql = $tool->getUpdateSchemaSql($classes);
$this->assertEquals(2, count($sql)); $this->assertEquals(2, count($sql));
$this->assertEquals("CREATE TABLE schematool_entity_b (id INT NOT NULL, field VARCHAR(255) NOT NULL, PRIMARY KEY(id))", $sql[0]); $this->assertEquals("CREATE TABLE schematool_entity_b (id INT NOT NULL, field VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]);
$this->assertEquals("ALTER TABLE schematool_entity_a ADD new_field VARCHAR(50) NOT NULL", $sql[1]); $this->assertEquals("ALTER TABLE schematool_entity_a ADD new_field VARCHAR(50) NOT NULL", $sql[1]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment