diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index ce058f88e..571e5872c 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -347,9 +347,11 @@ class Mysql extends DboSource { '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]; } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 6a93b09d5..b425740a3 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -3283,6 +3283,7 @@ class MysqlTest extends CakeTestCase { $this->assertArrayHasKey('unsigned', $schema[$type]); $this->assertFalse($schema[$type]['unsigned']); } + $this->assertArrayNotHasKey('unsigned', $schema['string']); } /** diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index 4f2e81f06..5f78af1d0 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -2216,7 +2216,8 @@ class ModelIntegrationTest extends BaseModelTest { 'null' => false, 'default' => null, 'length' => $intLength, - 'key' => 'primary' + 'key' => 'primary', + 'unsigned' => false ), 'user' => array( 'type' => 'string', diff --git a/lib/Cake/Test/Fixture/UnsignedFixture.php b/lib/Cake/Test/Fixture/UnsignedFixture.php index 1264ac9ae..e328de7dd 100644 --- a/lib/Cake/Test/Fixture/UnsignedFixture.php +++ b/lib/Cake/Test/Fixture/UnsignedFixture.php @@ -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' )