From b6372d63d95dd42c5cb984a5dd568aa062134303 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 11 Mar 2017 21:41:22 -0500 Subject: [PATCH] Rename (small|tiny)int to (small|tiny)integer Make the new types consistent with the biginteger. --- lib/Cake/Console/Command/Task/ModelTask.php | 4 +-- lib/Cake/Model/Datasource/Database/Mysql.php | 10 +++--- .../Model/Datasource/Database/Postgres.php | 6 ++-- lib/Cake/Model/Datasource/Database/Sqlite.php | 10 ++++-- .../Model/Datasource/Database/Sqlserver.php | 8 ++--- lib/Cake/Test/Case/Model/CakeSchemaTest.php | 4 +-- .../Model/Datasource/Database/MysqlTest.php | 32 +++++++++---------- .../Datasource/Database/PostgresTest.php | 2 +- .../Model/Datasource/Database/SqliteTest.php | 12 +++---- .../Datasource/Database/SqlserverTest.php | 4 +-- lib/Cake/Test/Fixture/DatatypeFixture.php | 4 +-- lib/Cake/Test/Fixture/UnsignedFixture.php | 8 ++--- lib/Cake/View/Helper/FormHelper.php | 4 +-- 13 files changed, 57 insertions(+), 51 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index c8a6ef381..eaba7b0ee 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -450,9 +450,9 @@ class ModelTask extends BakeTask { $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']; diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index fa6deab76..52310492c 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -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') ) ); @@ -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'), @@ -791,10 +791,10 @@ class Mysql extends DboSource { 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'; diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 9a827fc5f..341531320 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -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'), @@ -705,7 +705,7 @@ class Postgres extends DboSource { 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): diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 51a0dc375..6d34e7e4d 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -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'), @@ -275,6 +275,12 @@ class Sqlite extends DboSource { if (in_array($col, $standard)) { return $col; } + if ($col === 'tinyint') { + return 'tinyinteger'; + } + if ($col === 'smallint') { + return 'smallinteger'; + } if ($col === 'bigint') { return 'biginteger'; } diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 5bbf0a102..ee2fd3d85 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -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'), @@ -439,10 +439,10 @@ class Sqlserver extends DboSource { 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'; diff --git a/lib/Cake/Test/Case/Model/CakeSchemaTest.php b/lib/Cake/Test/Case/Model/CakeSchemaTest.php index b5f389d8e..be096484b 100644 --- a/lib/Cake/Test/Case/Model/CakeSchemaTest.php +++ b/lib/Cake/Test/Case/Model/CakeSchemaTest.php @@ -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() diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 6f4eca8b6..bfbdb5b6f 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -209,7 +209,7 @@ class MysqlTest extends CakeTestCase { $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'); @@ -527,11 +527,11 @@ class MysqlTest extends CakeTestCase { $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'); @@ -3291,7 +3291,7 @@ SQL; */ public function buildColumnUnsignedProvider() { return array( - //set #0 + // unsigned int array( array( 'name' => 'testName', @@ -3301,7 +3301,7 @@ SQL; ), '`testName` int(11) UNSIGNED' ), - //set #1 + // unsigned bigint array( array( 'name' => 'testName', @@ -3311,7 +3311,7 @@ SQL; ), '`testName` bigint(20) UNSIGNED' ), - //set #2 + // unsigned float array( array( 'name' => 'testName', @@ -3320,7 +3320,7 @@ SQL; ), '`testName` float UNSIGNED' ), - //set #3 + // varchar array( array( 'name' => 'testName', @@ -3330,7 +3330,7 @@ SQL; ), '`testName` varchar(255)' ), - //set #4 + // date unsigned array( array( 'name' => 'testName', @@ -3339,7 +3339,7 @@ SQL; ), '`testName` date' ), - //set #5 + // date array( array( 'name' => 'testName', @@ -3348,7 +3348,7 @@ SQL; ), '`testName` date' ), - //set #6 + // integer with length array( array( 'name' => 'testName', @@ -3358,7 +3358,7 @@ SQL; ), '`testName` int(11)' ), - //set #7 + // unsigned decimal array( array( 'name' => 'testName', @@ -3367,7 +3367,7 @@ SQL; ), '`testName` decimal UNSIGNED' ), - //set #8 + // decimal with default array( array( 'name' => 'testName', @@ -3377,21 +3377,21 @@ SQL; ), '`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 ), diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php index 68db54f33..bc423d8ac 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php @@ -306,7 +306,7 @@ class PostgresTest extends CakeTestCase { $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')); } /** diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php index ef206901a..b13bbb0ce 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php @@ -265,24 +265,24 @@ class SqliteTest extends CakeTestCase { $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( @@ -412,13 +412,13 @@ class SqliteTest extends CakeTestCase { '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 diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php index 5d7df51ad..f37f0a140 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php @@ -532,12 +532,12 @@ class SqlserverTest extends CakeTestCase { $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); diff --git a/lib/Cake/Test/Fixture/DatatypeFixture.php b/lib/Cake/Test/Fixture/DatatypeFixture.php index cf789b67e..68a3a9dbd 100644 --- a/lib/Cake/Test/Fixture/DatatypeFixture.php +++ b/lib/Cake/Test/Fixture/DatatypeFixture.php @@ -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), ); diff --git a/lib/Cake/Test/Fixture/UnsignedFixture.php b/lib/Cake/Test/Fixture/UnsignedFixture.php index a0eb97161..f6237d7e3 100644 --- a/lib/Cake/Test/Fixture/UnsignedFixture.php +++ b/lib/Cake/Test/Fixture/UnsignedFixture.php @@ -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), diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index d1463372a..c828d141c 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1245,8 +1245,8 @@ class FormHelper extends AppHelper { 'date' => 'date', 'float' => 'number', 'integer' => 'number', - 'smallint' => 'number', - 'tinyint' => 'number', + 'smallinteger' => 'number', + 'tinyinteger' => 'number', 'decimal' => 'number', 'binary' => 'file' );