Strip quotes from SQLite default column string values

parent a8fd3391
...@@ -137,6 +137,10 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -137,6 +137,10 @@ class SqliteSchemaManager extends AbstractSchemaManager
if ($default == 'NULL') { if ($default == 'NULL') {
$default = null; $default = null;
} }
if ($default !== null) {
// SQLite returns strings wrapped in single quotes, so we need to strip them
$default = preg_replace("/^'(.*)'$/", '\1', $default);
}
$notnull = (bool) $tableColumn['notnull']; $notnull = (bool) $tableColumn['notnull'];
if ( ! isset($tableColumn['name'])) { if ( ! isset($tableColumn['name'])) {
......
...@@ -99,7 +99,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -99,7 +99,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$table = new \Doctrine\DBAL\Schema\Table('list_table_columns'); $table = new \Doctrine\DBAL\Schema\Table('list_table_columns');
$table->addColumn('id', 'integer', array('notnull' => true)); $table->addColumn('id', 'integer', array('notnull' => true));
$table->addColumn('test', 'string', array('length' => 255, 'notnull' => false)); $table->addColumn('test', 'string', array('length' => 255, 'notnull' => false));
$table->addColumn('foo', 'text', array('notnull' => true)); $table->addColumn('foo', 'text', array('notnull' => true, 'default' => 'expected default'));
$table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false)); $table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false));
$table->addColumn('baz1', 'datetime'); $table->addColumn('baz1', 'datetime');
$table->addColumn('baz2', 'time'); $table->addColumn('baz2', 'time');
...@@ -138,7 +138,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -138,7 +138,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals(false, $columns['foo']->getunsigned()); $this->assertEquals(false, $columns['foo']->getunsigned());
$this->assertEquals(false, $columns['foo']->getfixed()); $this->assertEquals(false, $columns['foo']->getfixed());
$this->assertEquals(true, $columns['foo']->getnotnull()); $this->assertEquals(true, $columns['foo']->getnotnull());
$this->assertEquals(null, $columns['foo']->getdefault()); $this->assertEquals('expected default', $columns['foo']->getdefault());
$this->assertInternalType('array', $columns['foo']->getPlatformOptions()); $this->assertInternalType('array', $columns['foo']->getPlatformOptions());
$this->assertEquals('bar', strtolower($columns['bar']->getname())); $this->assertEquals('bar', strtolower($columns['bar']->getname()));
......
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