Skip to content

Commit

Permalink
not add unsigned to not numeric fields, fix broken test, add new test
Browse files Browse the repository at this point in the history
  • Loading branch information
imsamurai committed Nov 17, 2013
1 parent 2f6122c commit 8bcfe45
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/Cake/Model/Datasource/Database/Mysql.php
Expand Up @@ -347,9 +347,11 @@ public function describe($model) {
'type' => $this->column($column->Type),
'null' => ($column->Null === 'YES' ? true : false),
'default' => $column->Default,
'length' => $this->length($column->Type),
'unsigned' => $this->unsigned($column->Type)
'length' => $this->length($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])) {
$fields[$column->Field]['key'] = $this->index[$column->Key];
}
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Expand Up @@ -3283,6 +3283,7 @@ public function testSchemaUnsigned() {
$this->assertArrayHasKey('unsigned', $schema[$type]);
$this->assertFalse($schema[$type]['unsigned']);
}
$this->assertArrayNotHasKey('unsigned', $schema['string']);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Test/Case/Model/ModelIntegrationTest.php
Expand Up @@ -2216,7 +2216,8 @@ public function testCreation() {
'null' => false,
'default' => null,
'length' => $intLength,
'key' => 'primary'
'key' => 'primary',
'unsigned' => false
),
'user' => array(
'type' => 'string',
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Fixture/UnsignedFixture.php
Expand Up @@ -46,6 +46,7 @@ class UnsignedFixture extends CakeTestFixture {
'ubiginteger' => array('type' => 'biginteger', 'length' => '20', 'default' => 3, 'unsigned' => true),
'float' => array('type' => 'float', 'length' => '4'),
'ufloat' => array('type' => 'float', 'length' => '4', 'unsigned' => true),
'string' => array('type' => 'string', 'length' => '4'),
'tableParameters' => array(
'engine' => 'MyISAM'
)
Expand Down

0 comments on commit 8bcfe45

Please sign in to comment.