Commit 07de0dd8 authored by beberlei's avatar beberlei

Added additional Autoincrement state variable, preparing to remove it from platformOptions

parent ce5b0569
<?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
......@@ -75,6 +73,11 @@ class Column extends AbstractAsset
*/
protected $_default = null;
/**
* @var bool
*/
protected $_autoincrement = false;
/**
* @var array
*/
......@@ -302,6 +305,17 @@ class Column extends AbstractAsset
return $this->_columnDefinition;
}
public function getAutoincrement()
{
return $this->_autoincrement;
}
public function setAutoincrement($flag)
{
$this->_autoincrement = (bool)$flag;
return $this;
}
/**
* @param Visitor $visitor
*/
......@@ -325,6 +339,7 @@ class Column extends AbstractAsset
'scale' => $this->_scale,
'fixed' => $this->_fixed,
'unsigned' => $this->_unsigned,
'autoincrement' => $this->_autoincrement,
'columnDefinition' => $this->_columnDefinition,
), $this->_platformOptions);
}
......
......@@ -325,6 +325,10 @@ class Comparator
}
}
if ($column1->getAutoincrement() != $column2->getAutoincrement()) {
$changedProperties[] = 'autoincrement';
}
foreach ($column1->getPlatformOptions() AS $optionName => $optionValue) {
if (!$column2->hasPlatformOption($optionName) || $optionValue != $column2->getPlatformOption($optionName)) {
$changedProperties[] = $optionName;
......
......@@ -44,6 +44,7 @@ class ColumnTest extends \PHPUnit_Framework_TestCase
'scale' => 2,
'fixed' => true,
'unsigned' => true,
'autoincrement' => false,
'columnDefinition' => null,
'foo' => 'bar',
);
......
......@@ -111,6 +111,17 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
}
public function testCompareOnlyAutoincrementChanged()
{
$column1 = new Column('foo', Type::getType('integer'), array('autoincrement' => true));
$column2 = new Column('foo', Type::getType('integer'), array('autoincrement' => false));
$comparator = new Comparator();
$changedProperties = $comparator->diffColumn($column1, $column2);
$this->assertEquals(array('autoincrement'), $changedProperties);
}
public function testCompareMissingField()
{
$missingColumn = new Column('integerfield1', Type::getType('integer'));
......
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