Commit 3caada2b authored by beberlei's avatar beberlei

Fixed DBAL-2

parent ade10e9a
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -34,19 +32,6 @@ namespace Doctrine\DBAL\Schema;
*/
class Comparator
{
/**
* @var array
*/
private $_checkColumnPlatformOptions = array();
/**
* @param string $optionName
*/
public function addColumnPlatformOptionCheck($optionName)
{
$this->_checkColumnPlatformOptions[] = $optionName;
}
/**
* @param Schema $fromSchema
* @param Schema $toSchema
......@@ -340,12 +325,13 @@ class Comparator
}
}
foreach ($this->_checkColumnPlatformOptions AS $optionName) {
if($column1->hasPlatformOption($optionName) && $column2->hasPlatformOption($optionName)) {
if ($column1->getPlatformOption($optionName) != $column2->getPlatformOption($optionName)) {
foreach ($column1->getPlatformOptions() AS $optionName => $optionValue) {
if (!$column2->hasPlatformOption($optionName) || $optionValue != $column2->getPlatformOption($optionName)) {
$changedProperties[] = $optionName;
}
} else if ($column1->hasPlatformOption($optionName) != $column2->hasPlatformOption($optionName)) {
}
foreach ($column2->getPlatformOptions() AS $optionName => $optionValue) {
if (!$column1->hasPlatformOption($optionName)) {
$changedProperties[] = $optionName;
}
}
......
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
......@@ -572,6 +570,21 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('bar', $tableDiff->renamedColumns['foo']->getName());
}
public function testDetectChangeIdentifierType()
{
$tableA = new Table("foo");
$tableA->addColumn('id', 'integer', array('platformOptions' => array('autoincrement' => false)));
$tableB = new Table("foo");
$tableB->addColumn('id', 'integer', array('platformOptions' => array('autoincrement' => true)));
$c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB);
$this->assertType('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
$this->assertArrayHasKey('id', $tableDiff->changedColumns);
}
/**
* @param SchemaDiff $diff
* @param int $newTableCount
......
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