Commit 5cbe3ce8 authored by Steve Müller's avatar Steve Müller

Merge pull request #558 from deeky666/fix-sqlanywhere-default-values

Fix integer 0 default value reverse engineering on SQL Anywhere
parents dbee8cd7 534129d6
......@@ -109,7 +109,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
$fixed = false;
$default = null;
if ($tableColumn['default']) {
if (null !== $tableColumn['default']) {
// Strip quotes from default value.
$default = preg_replace(array("/^'(.*)'$/", "/''/"), array("$1", "'"), $tableColumn['default']);
......
......@@ -724,6 +724,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$table->addColumn('column4', 'string', array('default' => 0));
$table->addColumn('column5', 'string', array('default' => ''));
$table->addColumn('column6', 'string', array('default' => 'def'));
$table->addColumn('column7', 'integer', array('default' => 0));
$table->setPrimaryKey(array('id'));
$this->_sm->dropAndCreateTable($table);
......@@ -737,6 +738,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertSame('0', $columns['column4']->getDefault());
$this->assertSame('', $columns['column5']->getDefault());
$this->assertSame('def', $columns['column6']->getDefault());
$this->assertSame('0', $columns['column7']->getDefault());
$diffTable = clone $table;
......@@ -746,6 +748,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$diffTable->changeColumn('column4', array('default' => null));
$diffTable->changeColumn('column5', array('default' => false));
$diffTable->changeColumn('column6', array('default' => 666));
$diffTable->changeColumn('column7', array('default' => null));
$comparator = new Comparator();
......@@ -759,6 +762,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertNull($columns['column4']->getDefault());
$this->assertSame('', $columns['column5']->getDefault());
$this->assertSame('666', $columns['column6']->getDefault());
$this->assertNull($columns['column7']->getDefault());
}
public function testListTableWithBinary()
......
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