Skip to content

Commit

Permalink
Rename (small|tiny)int to (small|tiny)integer
Browse files Browse the repository at this point in the history
Make the new types consistent with the biginteger.
  • Loading branch information
markstory committed Mar 12, 2017
1 parent d78829b commit b6372d6
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 51 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/Task/ModelTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') {
$guess = $methods['notBlank'];
} elseif ($metaData['type'] === 'integer') {
$guess = $methods['numeric'];
} elseif ($metaData['type'] === 'smallint') {
} elseif ($metaData['type'] === 'smallinteger') {
$guess = $methods['numeric'];
} elseif ($metaData['type'] === 'tinyint') {
} elseif ($metaData['type'] === 'tinyinteger') {
$guess = $methods['numeric'];
} elseif ($metaData['type'] === 'float') {
$guess = $methods['numeric'];
Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/Model/Datasource/Database/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Mysql extends DboSource {
'position' => 'beforeDefault',
'noVal' => true,
'options' => array(true),
'types' => array('integer', 'smallint', 'tinyint', 'float', 'decimal', 'biginteger')
'types' => array('integer', 'smallinteger', 'tinyinteger', 'float', 'decimal', 'biginteger')
)
);

Expand Down Expand Up @@ -122,8 +122,8 @@ class Mysql extends DboSource {
'text' => array('name' => 'text'),
'biginteger' => array('name' => 'bigint', 'limit' => '20'),
'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
'smallint' => array('name' => 'smallint', 'limit' => '6', 'formatter' => 'intval'),
'tinyint' => array('name' => 'tinyint', 'limit' => '4', 'formatter' => 'intval'),
'smallinteger' => array('name' => 'smallint', 'limit' => '6', 'formatter' => 'intval'),
'tinyinteger' => array('name' => 'tinyint', 'limit' => '4', 'formatter' => 'intval'),
'float' => array('name' => 'float', 'formatter' => 'floatval'),
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
Expand Down Expand Up @@ -791,10 +791,10 @@ public function column($real) {
return 'biginteger';
}
if (strpos($col, 'tinyint') !== false) {
return 'tinyint';
return 'tinyinteger';
}
if (strpos($col, 'smallint') !== false) {
return 'smallint';
return 'smallinteger';
}
if (strpos($col, 'int') !== false) {
return 'integer';
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Model/Datasource/Database/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class Postgres extends DboSource {
'string' => array('name' => 'varchar', 'limit' => '255'),
'text' => array('name' => 'text'),
'integer' => array('name' => 'integer', 'formatter' => 'intval'),
'smallint' => array('name' => 'smallint', 'formatter' => 'intval'),
'tinyint' => array('name' => 'smallint', 'formatter' => 'intval'),
'smallinteger' => array('name' => 'smallint', 'formatter' => 'intval'),
'tinyinteger' => array('name' => 'smallint', 'formatter' => 'intval'),
'biginteger' => array('name' => 'bigint', 'limit' => '20'),
'float' => array('name' => 'float', 'formatter' => 'floatval'),
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
Expand Down Expand Up @@ -705,7 +705,7 @@ public function column($real) {
case ($col === 'bigint'):
return 'biginteger';
case ($col === 'smallint'):
return 'smallint';
return 'smallinteger';
case (strpos($col, 'int') !== false && $col !== 'interval'):
return 'integer';
case (strpos($col, 'char') !== false):
Expand Down
10 changes: 8 additions & 2 deletions lib/Cake/Model/Datasource/Database/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class Sqlite extends DboSource {
'string' => array('name' => 'varchar', 'limit' => '255'),
'text' => array('name' => 'text'),
'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'),
'smallint' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'),
'tinyint' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'),
'smallinteger' => array('name' => 'smallint', 'limit' => null, 'formatter' => 'intval'),
'tinyinteger' => array('name' => 'tinyint', 'limit' => null, 'formatter' => 'intval'),
'biginteger' => array('name' => 'bigint', 'limit' => 20),
'float' => array('name' => 'float', 'formatter' => 'floatval'),
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
Expand Down Expand Up @@ -275,6 +275,12 @@ public function column($real) {
if (in_array($col, $standard)) {
return $col;
}
if ($col === 'tinyint') {
return 'tinyinteger';
}
if ($col === 'smallint') {
return 'smallinteger';
}
if ($col === 'bigint') {
return 'biginteger';
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Model/Datasource/Database/Sqlserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class Sqlserver extends DboSource {
'string' => array('name' => 'nvarchar', 'limit' => '255'),
'text' => array('name' => 'nvarchar', 'limit' => 'MAX'),
'integer' => array('name' => 'int', 'formatter' => 'intval'),
'smallint' => array('name' => 'smallint', 'formatter' => 'intval'),
'tinyint' => array('name' => 'tinyint', 'formatter' => 'intval'),
'smallinteger' => array('name' => 'smallint', 'formatter' => 'intval'),
'tinyinteger' => array('name' => 'tinyint', 'formatter' => 'intval'),
'biginteger' => array('name' => 'bigint'),
'numeric' => array('name' => 'decimal', 'formatter' => 'floatval'),
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
Expand Down Expand Up @@ -439,10 +439,10 @@ public function column($real) {
return 'biginteger';
}
if (strpos($col, 'smallint') !== false) {
return 'smallint';
return 'smallinteger';
}
if (strpos($col, 'tinyint') !== false) {
return 'tinyint';
return 'tinyinteger';
}
if (strpos($col, 'int') !== false) {
return 'integer';
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Model/CakeSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ class TestAppSchema extends CakeSchema {
'decimal_field' => array('type' => 'decimal', 'length' => '6,3', 'default' => '0.000'),
'huge_int' => array('type' => 'biginteger'),
'normal_int' => array('type' => 'integer'),
'small_int' => array('type' => 'smallint'),
'tiny_int' => array('type' => 'tinyint'),
'small_int' => array('type' => 'smallinteger'),
'tiny_int' => array('type' => 'tinyinteger'),
'bool' => array('type' => 'boolean', 'null' => false, 'default' => false),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
'tableParameters' => array()
Expand Down
32 changes: 16 additions & 16 deletions lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function testTinyintCasting() {

$result = $this->model->schema();
$this->assertEquals('boolean', $result['bool']['type']);
$this->assertEquals('tinyint', $result['tiny_int']['type']);
$this->assertEquals('tinyinteger', $result['tiny_int']['type']);

$this->assertTrue((bool)$this->model->save(array('bool' => 5, 'tiny_int' => 5)));
$result = $this->model->find('first');
Expand Down Expand Up @@ -527,11 +527,11 @@ public function testColumn() {
$this->assertEquals($expected, $result);

$result = $this->Dbo->column('tinyint');
$expected = 'tinyint';
$expected = 'tinyinteger';
$this->assertEquals($expected, $result);

$result = $this->Dbo->column('smallint');
$expected = 'smallint';
$expected = 'smallinteger';
$this->assertEquals($expected, $result);

$result = $this->Dbo->column('boolean');
Expand Down Expand Up @@ -3291,7 +3291,7 @@ public function testBuildColumnUnsigned($data, $expected) {
*/
public function buildColumnUnsignedProvider() {
return array(
//set #0
// unsigned int
array(
array(
'name' => 'testName',
Expand All @@ -3301,7 +3301,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` int(11) UNSIGNED'
),
//set #1
// unsigned bigint
array(
array(
'name' => 'testName',
Expand All @@ -3311,7 +3311,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` bigint(20) UNSIGNED'
),
//set #2
// unsigned float
array(
array(
'name' => 'testName',
Expand All @@ -3320,7 +3320,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` float UNSIGNED'
),
//set #3
// varchar
array(
array(
'name' => 'testName',
Expand All @@ -3330,7 +3330,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` varchar(255)'
),
//set #4
// date unsigned
array(
array(
'name' => 'testName',
Expand All @@ -3339,7 +3339,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` date'
),
//set #5
// date
array(
array(
'name' => 'testName',
Expand All @@ -3348,7 +3348,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` date'
),
//set #6
// integer with length
array(
array(
'name' => 'testName',
Expand All @@ -3358,7 +3358,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` int(11)'
),
//set #7
// unsigned decimal
array(
array(
'name' => 'testName',
Expand All @@ -3367,7 +3367,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` decimal UNSIGNED'
),
//set #8
// decimal with default
array(
array(
'name' => 'testName',
Expand All @@ -3377,21 +3377,21 @@ public function buildColumnUnsignedProvider() {
),
'`testName` decimal UNSIGNED DEFAULT 1'
),
//set #9
// smallinteger
array(
array(
'name' => 'testName',
'type' => 'smallint',
'type' => 'smallinteger',
'length' => 6,
'unsigned' => true
),
'`testName` smallint(6) UNSIGNED'
),
//set #10
// tinyinteger
array(
array(
'name' => 'testName',
'type' => 'tinyint',
'type' => 'tinyinteger',
'length' => 4,
'unsigned' => true
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public function testColumnParsing() {

$this->assertEquals('biginteger', $this->Dbo2->column('bigint'));
$this->assertEquals('integer', $this->Dbo2->column('integer'));
$this->assertEquals('smallint', $this->Dbo2->column('smallint'));
$this->assertEquals('smallinteger', $this->Dbo2->column('smallint'));
}

/**
Expand Down
12 changes: 6 additions & 6 deletions lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,24 +265,24 @@ public function testBuildColumn() {

$data = array(
'name' => 'testName',
'type' => 'smallint',
'type' => 'smallinteger',
'length' => 6,
'default' => 6,
'null' => false,
);
$result = $this->Dbo->buildColumn($data);
$expected = '"testName" integer(6) DEFAULT 6 NOT NULL';
$expected = '"testName" smallint(6) DEFAULT 6 NOT NULL';
$this->assertEquals($expected, $result);

$data = array(
'name' => 'testName',
'type' => 'tinyint',
'type' => 'tinyinteger',
'length' => 4,
'default' => 4,
'null' => false,
);
$result = $this->Dbo->buildColumn($data);
$expected = '"testName" integer(4) DEFAULT 4 NOT NULL';
$expected = '"testName" tinyint(4) DEFAULT 4 NOT NULL';
$this->assertEquals($expected, $result);

$data = array(
Expand Down Expand Up @@ -412,13 +412,13 @@ public function testDatatypes() {
'length' => null
),
'small_int' => array(
'type' => 'integer',
'type' => 'smallinteger',
'null' => true,
'default' => null,
'length' => null
),
'tiny_int' => array(
'type' => 'integer',
'type' => 'tinyinteger',
'null' => true,
'default' => null,
'length' => null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,12 @@ public function testBuildColumn() {
$expected = '[client_id] int NULL';
$this->assertEquals($expected, $result);

$column = array('type' => 'smallint', 'name' => 'client_id');
$column = array('type' => 'smallinteger', 'name' => 'client_id');
$result = $this->db->buildColumn($column);
$expected = '[client_id] smallint NULL';
$this->assertEquals($expected, $result);

$column = array('type' => 'tinyint', 'name' => 'client_id');
$column = array('type' => 'tinyinteger', 'name' => 'client_id');
$result = $this->db->buildColumn($column);
$expected = '[client_id] tinyint NULL';
$this->assertEquals($expected, $result);
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Fixture/DatatypeFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class DatatypeFixture extends CakeTestFixture {
'decimal_field' => array('type' => 'decimal', 'length' => '6,3', 'default' => '0.000'),
'huge_int' => array('type' => 'biginteger'),
'normal_int' => array('type' => 'integer'),
'small_int' => array('type' => 'smallint'),
'tiny_int' => array('type' => 'tinyint'),
'small_int' => array('type' => 'smallinteger'),
'tiny_int' => array('type' => 'tinyinteger'),
'bool' => array('type' => 'boolean', 'null' => false, 'default' => false),
);

Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Test/Fixture/UnsignedFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class UnsignedFixture extends CakeTestFixture {
public $fields = array(
'uinteger' => array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key' => 'primary', 'unsigned' => true),
'integer' => array('type' => 'integer', 'length' => '8', 'unsigned' => false),
'usmallint' => array('type' => 'smallint', 'unsigned' => true),
'smallint' => array('type' => 'smallint', 'unsigned' => false),
'utinyint' => array('type' => 'tinyint', 'unsigned' => true),
'tinyint' => array('type' => 'tinyint', 'unsigned' => false),
'usmallinteger' => array('type' => 'smallinteger', 'unsigned' => true),
'smallinteger' => array('type' => 'smallinteger', 'unsigned' => false),
'utinyinteger' => array('type' => 'tinyinteger', 'unsigned' => true),
'tinyinteger' => array('type' => 'tinyinteger', 'unsigned' => false),
'udecimal' => array('type' => 'decimal', 'length' => '4', 'unsigned' => true),
'decimal' => array('type' => 'decimal', 'length' => '4'),
'biginteger' => array('type' => 'biginteger', 'length' => '20', 'default' => 3),
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/View/Helper/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1245,8 +1245,8 @@ protected function _magicOptions($options) {
'date' => 'date',
'float' => 'number',
'integer' => 'number',
'smallint' => 'number',
'tinyint' => 'number',
'smallinteger' => 'number',
'tinyinteger' => 'number',
'decimal' => 'number',
'binary' => 'file'
);
Expand Down

0 comments on commit b6372d6

Please sign in to comment.