not add unsigned to not numeric fields, fix broken test, add new test

This commit is contained in:
imsamurai 2013-11-17 23:10:53 +02:00
parent 2f6122cb01
commit 8bcfe452da
4 changed files with 8 additions and 3 deletions

View file

@ -347,9 +347,11 @@ class Mysql extends DboSource {
'type' => $this->column($column->Type), 'type' => $this->column($column->Type),
'null' => ($column->Null === 'YES' ? true : false), 'null' => ($column->Null === 'YES' ? true : false),
'default' => $column->Default, 'default' => $column->Default,
'length' => $this->length($column->Type), 'length' => $this->length($column->Type)
'unsigned' => $this->unsigned($column->Type)
); );
if (in_array($fields[$column->Field]['type'], $this->fieldParameters['unsigned']['types'], true)) {
$fields[$column->Field]['unsigned'] = $this->unsigned($column->Type);
}
if (!empty($column->Key) && isset($this->index[$column->Key])) { if (!empty($column->Key) && isset($this->index[$column->Key])) {
$fields[$column->Field]['key'] = $this->index[$column->Key]; $fields[$column->Field]['key'] = $this->index[$column->Key];
} }

View file

@ -3283,6 +3283,7 @@ class MysqlTest extends CakeTestCase {
$this->assertArrayHasKey('unsigned', $schema[$type]); $this->assertArrayHasKey('unsigned', $schema[$type]);
$this->assertFalse($schema[$type]['unsigned']); $this->assertFalse($schema[$type]['unsigned']);
} }
$this->assertArrayNotHasKey('unsigned', $schema['string']);
} }
/** /**

View file

@ -2216,7 +2216,8 @@ class ModelIntegrationTest extends BaseModelTest {
'null' => false, 'null' => false,
'default' => null, 'default' => null,
'length' => $intLength, 'length' => $intLength,
'key' => 'primary' 'key' => 'primary',
'unsigned' => false
), ),
'user' => array( 'user' => array(
'type' => 'string', 'type' => 'string',

View file

@ -46,6 +46,7 @@ class UnsignedFixture extends CakeTestFixture {
'ubiginteger' => array('type' => 'biginteger', 'length' => '20', 'default' => 3, 'unsigned' => true), 'ubiginteger' => array('type' => 'biginteger', 'length' => '20', 'default' => 3, 'unsigned' => true),
'float' => array('type' => 'float', 'length' => '4'), 'float' => array('type' => 'float', 'length' => '4'),
'ufloat' => array('type' => 'float', 'length' => '4', 'unsigned' => true), 'ufloat' => array('type' => 'float', 'length' => '4', 'unsigned' => true),
'string' => array('type' => 'string', 'length' => '4'),
'tableParameters' => array( 'tableParameters' => array(
'engine' => 'MyISAM' 'engine' => 'MyISAM'
) )