Browse Source

Rename (small|tiny)int to (small|tiny)integer

This makes the naming consistent across integer, biginteger and the new
smaller versions.
Mark Story 9 years ago
parent
commit
f40e027455

+ 7 - 7
src/Database/Schema/MysqlSchema.php

@@ -104,12 +104,12 @@ class MysqlSchema extends BaseSchema
             return ['type' => 'biginteger', 'length' => $length, 'unsigned' => $unsigned];
         }
         if ($col === 'tinyint') {
-            return ['type' => 'tinyint', 'length' => $length, 'unsigned' => $unsigned];
+            return ['type' => 'tinyinteger', 'length' => $length, 'unsigned' => $unsigned];
         }
         if ($col === 'smallint') {
-            return ['type' => 'smallint', 'length' => $length, 'unsigned' => $unsigned];
+            return ['type' => 'smallinteger', 'length' => $length, 'unsigned' => $unsigned];
         }
-        if (in_array($col, ['int', 'integer', 'tinyint', 'smallint', 'mediumint'])) {
+        if (in_array($col, ['int', 'integer', 'mediumint'])) {
             return ['type' => 'integer', 'length' => $length, 'unsigned' => $unsigned];
         }
         if ($col === 'char' && $length === 36) {
@@ -303,8 +303,8 @@ class MysqlSchema extends BaseSchema
         $nativeJson = $this->_driver->supportsNativeJson();
 
         $typeMap = [
-            'tinyint' => ' TINYINT',
-            'smallint' => ' SMALLINT',
+            'tinyinteger' => ' TINYINT',
+            'smallinteger' => ' SMALLINT',
             'integer' => ' INTEGER',
             'biginteger' => ' BIGINT',
             'boolean' => ' BOOLEAN',
@@ -361,7 +361,7 @@ class MysqlSchema extends BaseSchema
                     break;
             }
         }
-        $hasLength = ['integer', 'smallint', 'tinyint', 'string'];
+        $hasLength = ['integer', 'smallinteger', 'tinyinteger', 'string'];
         if (in_array($data['type'], $hasLength, true) && isset($data['length'])) {
             $out .= '(' . (int)$data['length'] . ')';
         }
@@ -373,7 +373,7 @@ class MysqlSchema extends BaseSchema
             $out .= '(' . (int)$data['length'] . ',' . (int)$data['precision'] . ')';
         }
 
-        $hasUnsigned = ['float', 'decimal', 'tinyint', 'smallint', 'integer', 'biginteger'];
+        $hasUnsigned = ['float', 'decimal', 'tinyinteger', 'smallinteger', 'integer', 'biginteger'];
         if (in_array($data['type'], $hasUnsigned, true) &&
             isset($data['unsigned']) && $data['unsigned'] === true
         ) {

+ 3 - 3
src/Database/Schema/PostgresSchema.php

@@ -102,7 +102,7 @@ class PostgresSchema extends BaseSchema
             return ['type' => 'biginteger', 'length' => 20];
         }
         if ($col === 'smallint') {
-            return ['type' => 'smallint', 'length' => 5];
+            return ['type' => 'smallinteger', 'length' => 5];
         }
         if ($col === 'inet') {
             return ['type' => 'string', 'length' => 39];
@@ -351,8 +351,8 @@ class PostgresSchema extends BaseSchema
         $data = $schema->column($name);
         $out = $this->_driver->quoteIdentifier($name);
         $typeMap = [
-            'tinyint' => ' SMALLINT',
-            'smallint' => ' SMALLINT',
+            'tinyinteger' => ' SMALLINT',
+            'smallinteger' => ' SMALLINT',
             'boolean' => ' BOOLEAN',
             'binary' => ' BYTEA',
             'float' => ' FLOAT',

+ 6 - 6
src/Database/Schema/SqliteSchema.php

@@ -69,10 +69,10 @@ class SqliteSchema extends BaseSchema
             return ['type' => 'biginteger', 'length' => $length, 'unsigned' => $unsigned];
         }
         if ($col == 'smallint') {
-            return ['type' => 'smallint', 'length' => $length, 'unsigned' => $unsigned];
+            return ['type' => 'smallinteger', 'length' => $length, 'unsigned' => $unsigned];
         }
         if ($col == 'tinyint') {
-            return ['type' => 'tinyint', 'length' => $length, 'unsigned' => $unsigned];
+            return ['type' => 'tinyinteger', 'length' => $length, 'unsigned' => $unsigned];
         }
         if (strpos($col, 'int') !== false) {
             return ['type' => 'integer', 'length' => $length, 'unsigned' => $unsigned];
@@ -284,8 +284,8 @@ class SqliteSchema extends BaseSchema
         $data = $schema->column($name);
         $typeMap = [
             'uuid' => ' CHAR(36)',
-            'smallint' => ' SMALLINT',
-            'tinyint' => ' TINYINT',
+            'smallinteger' => ' SMALLINT',
+            'tinyinteger' => ' TINYINT',
             'integer' => ' INTEGER',
             'biginteger' => ' BIGINT',
             'boolean' => ' BOOLEAN',
@@ -300,7 +300,7 @@ class SqliteSchema extends BaseSchema
         ];
 
         $out = $this->_driver->quoteIdentifier($name);
-        $hasUnsigned = ['smallint', 'tinyint', 'biginteger', 'integer', 'float', 'decimal'];
+        $hasUnsigned = ['smallinteger', 'tinyinteger', 'biginteger', 'integer', 'float', 'decimal'];
 
         if (in_array($data['type'], $hasUnsigned, true) &&
             isset($data['unsigned']) && $data['unsigned'] === true
@@ -326,7 +326,7 @@ class SqliteSchema extends BaseSchema
             }
         }
 
-        $integerTypes = ['integer', 'smallint', 'tinyint'];
+        $integerTypes = ['integer', 'smallinteger', 'tinyinteger'];
         if (in_array($data['type'], $integerTypes, true) &&
             isset($data['length']) && [$name] !== (array)$schema->primaryKey()
         ) {

+ 4 - 4
src/Database/Schema/SqlserverSchema.php

@@ -89,10 +89,10 @@ class SqlserverSchema extends BaseSchema
         }
 
         if ($col === 'tinyint') {
-            return ['type' => 'tinyint', 'length' => $precision ?: 3];
+            return ['type' => 'tinyinteger', 'length' => $precision ?: 3];
         }
         if ($col === 'smallint') {
-            return ['type' => 'smallint', 'length' => $precision ?: 5];
+            return ['type' => 'smallinteger', 'length' => $precision ?: 5];
         }
         if ($col === 'int' || $col === 'integer') {
             return ['type' => 'integer', 'length' => $precision ?: 10];
@@ -331,8 +331,8 @@ class SqlserverSchema extends BaseSchema
         $data = $schema->column($name);
         $out = $this->_driver->quoteIdentifier($name);
         $typeMap = [
-            'tinyint' => ' TINYINT',
-            'smallint' => ' SMALLINT',
+            'tinyinteger' => ' TINYINT',
+            'smallinteger' => ' SMALLINT',
             'integer' => ' INTEGER',
             'biginteger' => ' BIGINT',
             'boolean' => ' BIT',

+ 2 - 2
src/Database/Schema/TableSchema.php

@@ -142,10 +142,10 @@ class TableSchema
         'text' => [
             'collate' => null,
         ],
-        'tinyint' => [
+        'tinyinteger' => [
             'unsigned' => null,
         ],
-        'smallint' => [
+        'smallinteger' => [
             'unsigned' => null,
         ],
         'integer' => [

+ 2 - 2
src/View/Helper/FormHelper.php

@@ -93,8 +93,8 @@ class FormHelper extends Helper
             'date' => 'date',
             'float' => 'number',
             'integer' => 'number',
-            'tinyint' => 'number',
-            'smallint' => 'number',
+            'tinyinteger' => 'number',
+            'smallinteger' => 'number',
             'decimal' => 'number',
             'binary' => 'file',
             'uuid' => 'string'

+ 9 - 9
tests/TestCase/Database/Schema/MysqlSchemaTest.php

@@ -69,23 +69,23 @@ class MysqlSchemaTest extends TestCase
             ],
             [
                 'TINYINT(2)',
-                ['type' => 'tinyint', 'length' => 2, 'unsigned' => false]
+                ['type' => 'tinyinteger', 'length' => 2, 'unsigned' => false]
             ],
             [
                 'TINYINT(3)',
-                ['type' => 'tinyint', 'length' => 3, 'unsigned' => false]
+                ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => false]
             ],
             [
                 'TINYINT(3) UNSIGNED',
-                ['type' => 'tinyint', 'length' => 3, 'unsigned' => true]
+                ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => true]
             ],
             [
                 'SMALLINT(4)',
-                ['type' => 'smallint', 'length' => 4, 'unsigned' => false]
+                ['type' => 'smallinteger', 'length' => 4, 'unsigned' => false]
             ],
             [
                 'SMALLINT(4) UNSIGNED',
-                ['type' => 'smallint', 'length' => 4, 'unsigned' => true]
+                ['type' => 'smallinteger', 'length' => 4, 'unsigned' => true]
             ],
             [
                 'INTEGER(11)',
@@ -585,22 +585,22 @@ SQL;
             // Integers
             [
                 'post_id',
-                ['type' => 'tinyint', 'length' => 2],
+                ['type' => 'tinyinteger', 'length' => 2],
                 '`post_id` TINYINT(2)'
             ],
             [
                 'post_id',
-                ['type' => 'tinyint', 'length' => 2, 'unsigned' => true],
+                ['type' => 'tinyinteger', 'length' => 2, 'unsigned' => true],
                 '`post_id` TINYINT(2) UNSIGNED'
             ],
             [
                 'post_id',
-                ['type' => 'smallint', 'length' => 4],
+                ['type' => 'smallinteger', 'length' => 4],
                 '`post_id` SMALLINT(4)'
             ],
             [
                 'post_id',
-                ['type' => 'smallint', 'length' => 4, 'unsigned' => true],
+                ['type' => 'smallinteger', 'length' => 4, 'unsigned' => true],
                 '`post_id` SMALLINT(4) UNSIGNED'
             ],
             [

+ 4 - 4
tests/TestCase/Database/Schema/PostgresSchemaTest.php

@@ -121,7 +121,7 @@ SQL;
             // Integer
             [
                 'SMALLINT',
-                ['type' => 'smallint', 'length' => 5]
+                ['type' => 'smallinteger', 'length' => 5]
             ],
             [
                 'INTEGER',
@@ -352,7 +352,7 @@ SQL;
                 'comment' => null,
             ],
             'views' => [
-                'type' => 'smallint',
+                'type' => 'smallinteger',
                 'null' => true,
                 'default' => 0,
                 'length' => 5,
@@ -708,12 +708,12 @@ SQL;
             // Integers
             [
                 'post_id',
-                ['type' => 'tinyint', 'length' => 11],
+                ['type' => 'tinyinteger', 'length' => 11],
                 '"post_id" SMALLINT'
             ],
             [
                 'post_id',
-                ['type' => 'smallint', 'length' => 11],
+                ['type' => 'smallinteger', 'length' => 11],
                 '"post_id" SMALLINT'
             ],
             [

+ 8 - 8
tests/TestCase/Database/Schema/SqliteSchemaTest.php

@@ -97,19 +97,19 @@ class SqliteSchemaTest extends TestCase
             ],
             [
                 'TINYINT(3)',
-                ['type' => 'tinyint', 'length' => 3, 'unsigned' => false]
+                ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => false]
             ],
             [
                 'UNSIGNED TINYINT(3)',
-                ['type' => 'tinyint', 'length' => 3, 'unsigned' => true]
+                ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => true]
             ],
             [
                 'SMALLINT(5)',
-                ['type' => 'smallint', 'length' => 5, 'unsigned' => false]
+                ['type' => 'smallinteger', 'length' => 5, 'unsigned' => false]
             ],
             [
                 'UNSIGNED SMALLINT(5)',
-                ['type' => 'smallint', 'length' => 5, 'unsigned' => true]
+                ['type' => 'smallinteger', 'length' => 5, 'unsigned' => true]
             ],
             [
                 'MEDIUMINT(10)',
@@ -511,22 +511,22 @@ SQL;
             // Integers
             [
                 'post_id',
-                ['type' => 'smallint', 'length' => 5, 'unsigned' => false],
+                ['type' => 'smallinteger', 'length' => 5, 'unsigned' => false],
                 '"post_id" SMALLINT(5)'
             ],
             [
                 'post_id',
-                ['type' => 'smallint', 'length' => 5, 'unsigned' => true],
+                ['type' => 'smallinteger', 'length' => 5, 'unsigned' => true],
                 '"post_id" UNSIGNED SMALLINT(5)'
             ],
             [
                 'post_id',
-                ['type' => 'tinyint', 'length' => 3, 'unsigned' => false],
+                ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => false],
                 '"post_id" TINYINT(3)'
             ],
             [
                 'post_id',
-                ['type' => 'tinyint', 'length' => 3, 'unsigned' => true],
+                ['type' => 'tinyinteger', 'length' => 3, 'unsigned' => true],
                 '"post_id" UNSIGNED TINYINT(3)'
             ],
             [

+ 6 - 6
tests/TestCase/Database/Schema/SqlserverSchemaTest.php

@@ -114,28 +114,28 @@ SQL;
                 null,
                 2,
                 null,
-                ['type' => 'tinyint', 'length' => 2]
+                ['type' => 'tinyinteger', 'length' => 2]
             ],
             [
                 'TINYINT',
                 null,
                 null,
                 null,
-                ['type' => 'tinyint', 'length' => 3]
+                ['type' => 'tinyinteger', 'length' => 3]
             ],
             [
                 'SMALLINT',
                 null,
                 3,
                 null,
-                ['type' => 'smallint', 'length' => 3]
+                ['type' => 'smallinteger', 'length' => 3]
             ],
             [
                 'SMALLINT',
                 null,
                 null,
                 null,
-                ['type' => 'smallint', 'length' => 5]
+                ['type' => 'smallinteger', 'length' => 5]
             ],
             [
                 'INTEGER',
@@ -576,12 +576,12 @@ SQL;
             // Integers
             [
                 'post_id',
-                ['type' => 'smallint', 'length' => 11],
+                ['type' => 'smallinteger', 'length' => 11],
                 '[post_id] SMALLINT'
             ],
             [
                 'post_id',
-                ['type' => 'tinyint', 'length' => 11],
+                ['type' => 'tinyinteger', 'length' => 11],
                 '[post_id] TINYINT'
             ],
             [

+ 2 - 2
tests/TestCase/View/Helper/FormHelperTest.php

@@ -1227,7 +1227,7 @@ class FormHelperTest extends TestCase
     {
         $this->article['schema'] = [
             'foo' => [
-                'type' => 'smallint',
+                'type' => 'smallinteger',
                 'null' => false,
                 'default' => null,
                 'length' => 10
@@ -1249,7 +1249,7 @@ class FormHelperTest extends TestCase
     {
         $this->article['schema'] = [
             'foo' => [
-                'type' => 'tinyint',
+                'type' => 'tinyinteger',
                 'null' => false,
                 'default' => null,
                 'length' => 10