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

Make the new types consistent with the biginteger.
This commit is contained in:
mark_story 2017-03-11 21:41:22 -05:00
parent d78829bd93
commit b6372d63d9
13 changed files with 57 additions and 51 deletions

View file

@ -450,9 +450,9 @@ class ModelTask extends BakeTask {
$guess = $methods['notBlank']; $guess = $methods['notBlank'];
} elseif ($metaData['type'] === 'integer') { } elseif ($metaData['type'] === 'integer') {
$guess = $methods['numeric']; $guess = $methods['numeric'];
} elseif ($metaData['type'] === 'smallint') { } elseif ($metaData['type'] === 'smallinteger') {
$guess = $methods['numeric']; $guess = $methods['numeric'];
} elseif ($metaData['type'] === 'tinyint') { } elseif ($metaData['type'] === 'tinyinteger') {
$guess = $methods['numeric']; $guess = $methods['numeric'];
} elseif ($metaData['type'] === 'float') { } elseif ($metaData['type'] === 'float') {
$guess = $methods['numeric']; $guess = $methods['numeric'];

View file

@ -94,7 +94,7 @@ class Mysql extends DboSource {
'position' => 'beforeDefault', 'position' => 'beforeDefault',
'noVal' => true, 'noVal' => true,
'options' => array(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'), 'text' => array('name' => 'text'),
'biginteger' => array('name' => 'bigint', 'limit' => '20'), 'biginteger' => array('name' => 'bigint', 'limit' => '20'),
'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), 'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
'smallint' => array('name' => 'smallint', 'limit' => '6', 'formatter' => 'intval'), 'smallinteger' => array('name' => 'smallint', 'limit' => '6', 'formatter' => 'intval'),
'tinyint' => array('name' => 'tinyint', 'limit' => '4', 'formatter' => 'intval'), 'tinyinteger' => array('name' => 'tinyint', 'limit' => '4', 'formatter' => 'intval'),
'float' => array('name' => 'float', 'formatter' => 'floatval'), 'float' => array('name' => 'float', 'formatter' => 'floatval'),
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'), 'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
@ -791,10 +791,10 @@ class Mysql extends DboSource {
return 'biginteger'; return 'biginteger';
} }
if (strpos($col, 'tinyint') !== false) { if (strpos($col, 'tinyint') !== false) {
return 'tinyint'; return 'tinyinteger';
} }
if (strpos($col, 'smallint') !== false) { if (strpos($col, 'smallint') !== false) {
return 'smallint'; return 'smallinteger';
} }
if (strpos($col, 'int') !== false) { if (strpos($col, 'int') !== false) {
return 'integer'; return 'integer';

View file

@ -59,8 +59,8 @@ class Postgres extends DboSource {
'string' => array('name' => 'varchar', 'limit' => '255'), 'string' => array('name' => 'varchar', 'limit' => '255'),
'text' => array('name' => 'text'), 'text' => array('name' => 'text'),
'integer' => array('name' => 'integer', 'formatter' => 'intval'), 'integer' => array('name' => 'integer', 'formatter' => 'intval'),
'smallint' => array('name' => 'smallint', 'formatter' => 'intval'), 'smallinteger' => array('name' => 'smallint', 'formatter' => 'intval'),
'tinyint' => array('name' => 'smallint', 'formatter' => 'intval'), 'tinyinteger' => array('name' => 'smallint', 'formatter' => 'intval'),
'biginteger' => array('name' => 'bigint', 'limit' => '20'), 'biginteger' => array('name' => 'bigint', 'limit' => '20'),
'float' => array('name' => 'float', 'formatter' => 'floatval'), 'float' => array('name' => 'float', 'formatter' => 'floatval'),
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'), 'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
@ -705,7 +705,7 @@ class Postgres extends DboSource {
case ($col === 'bigint'): case ($col === 'bigint'):
return 'biginteger'; return 'biginteger';
case ($col === 'smallint'): case ($col === 'smallint'):
return 'smallint'; return 'smallinteger';
case (strpos($col, 'int') !== false && $col !== 'interval'): case (strpos($col, 'int') !== false && $col !== 'interval'):
return 'integer'; return 'integer';
case (strpos($col, 'char') !== false): case (strpos($col, 'char') !== false):

View file

@ -71,8 +71,8 @@ class Sqlite extends DboSource {
'string' => array('name' => 'varchar', 'limit' => '255'), 'string' => array('name' => 'varchar', 'limit' => '255'),
'text' => array('name' => 'text'), 'text' => array('name' => 'text'),
'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'), 'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'),
'smallint' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'), 'smallinteger' => array('name' => 'smallint', 'limit' => null, 'formatter' => 'intval'),
'tinyint' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'), 'tinyinteger' => array('name' => 'tinyint', 'limit' => null, 'formatter' => 'intval'),
'biginteger' => array('name' => 'bigint', 'limit' => 20), 'biginteger' => array('name' => 'bigint', 'limit' => 20),
'float' => array('name' => 'float', 'formatter' => 'floatval'), 'float' => array('name' => 'float', 'formatter' => 'floatval'),
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'), 'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
@ -275,6 +275,12 @@ class Sqlite extends DboSource {
if (in_array($col, $standard)) { if (in_array($col, $standard)) {
return $col; return $col;
} }
if ($col === 'tinyint') {
return 'tinyinteger';
}
if ($col === 'smallint') {
return 'smallinteger';
}
if ($col === 'bigint') { if ($col === 'bigint') {
return 'biginteger'; return 'biginteger';
} }

View file

@ -92,8 +92,8 @@ class Sqlserver extends DboSource {
'string' => array('name' => 'nvarchar', 'limit' => '255'), 'string' => array('name' => 'nvarchar', 'limit' => '255'),
'text' => array('name' => 'nvarchar', 'limit' => 'MAX'), 'text' => array('name' => 'nvarchar', 'limit' => 'MAX'),
'integer' => array('name' => 'int', 'formatter' => 'intval'), 'integer' => array('name' => 'int', 'formatter' => 'intval'),
'smallint' => array('name' => 'smallint', 'formatter' => 'intval'), 'smallinteger' => array('name' => 'smallint', 'formatter' => 'intval'),
'tinyint' => array('name' => 'tinyint', 'formatter' => 'intval'), 'tinyinteger' => array('name' => 'tinyint', 'formatter' => 'intval'),
'biginteger' => array('name' => 'bigint'), 'biginteger' => array('name' => 'bigint'),
'numeric' => array('name' => 'decimal', 'formatter' => 'floatval'), 'numeric' => array('name' => 'decimal', 'formatter' => 'floatval'),
'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'), 'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'),
@ -439,10 +439,10 @@ class Sqlserver extends DboSource {
return 'biginteger'; return 'biginteger';
} }
if (strpos($col, 'smallint') !== false) { if (strpos($col, 'smallint') !== false) {
return 'smallint'; return 'smallinteger';
} }
if (strpos($col, 'tinyint') !== false) { if (strpos($col, 'tinyint') !== false) {
return 'tinyint'; return 'tinyinteger';
} }
if (strpos($col, 'int') !== false) { if (strpos($col, 'int') !== false) {
return 'integer'; return 'integer';

View file

@ -174,8 +174,8 @@ class TestAppSchema extends CakeSchema {
'decimal_field' => array('type' => 'decimal', 'length' => '6,3', 'default' => '0.000'), 'decimal_field' => array('type' => 'decimal', 'length' => '6,3', 'default' => '0.000'),
'huge_int' => array('type' => 'biginteger'), 'huge_int' => array('type' => 'biginteger'),
'normal_int' => array('type' => 'integer'), 'normal_int' => array('type' => 'integer'),
'small_int' => array('type' => 'smallint'), 'small_int' => array('type' => 'smallinteger'),
'tiny_int' => array('type' => 'tinyint'), 'tiny_int' => array('type' => 'tinyinteger'),
'bool' => array('type' => 'boolean', 'null' => false, 'default' => false), 'bool' => array('type' => 'boolean', 'null' => false, 'default' => false),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
'tableParameters' => array() 'tableParameters' => array()

View file

@ -209,7 +209,7 @@ class MysqlTest extends CakeTestCase {
$result = $this->model->schema(); $result = $this->model->schema();
$this->assertEquals('boolean', $result['bool']['type']); $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))); $this->assertTrue((bool)$this->model->save(array('bool' => 5, 'tiny_int' => 5)));
$result = $this->model->find('first'); $result = $this->model->find('first');
@ -527,11 +527,11 @@ class MysqlTest extends CakeTestCase {
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Dbo->column('tinyint'); $result = $this->Dbo->column('tinyint');
$expected = 'tinyint'; $expected = 'tinyinteger';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Dbo->column('smallint'); $result = $this->Dbo->column('smallint');
$expected = 'smallint'; $expected = 'smallinteger';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Dbo->column('boolean'); $result = $this->Dbo->column('boolean');
@ -3291,7 +3291,7 @@ SQL;
*/ */
public function buildColumnUnsignedProvider() { public function buildColumnUnsignedProvider() {
return array( return array(
//set #0 // unsigned int
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
@ -3301,7 +3301,7 @@ SQL;
), ),
'`testName` int(11) UNSIGNED' '`testName` int(11) UNSIGNED'
), ),
//set #1 // unsigned bigint
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
@ -3311,7 +3311,7 @@ SQL;
), ),
'`testName` bigint(20) UNSIGNED' '`testName` bigint(20) UNSIGNED'
), ),
//set #2 // unsigned float
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
@ -3320,7 +3320,7 @@ SQL;
), ),
'`testName` float UNSIGNED' '`testName` float UNSIGNED'
), ),
//set #3 // varchar
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
@ -3330,7 +3330,7 @@ SQL;
), ),
'`testName` varchar(255)' '`testName` varchar(255)'
), ),
//set #4 // date unsigned
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
@ -3339,7 +3339,7 @@ SQL;
), ),
'`testName` date' '`testName` date'
), ),
//set #5 // date
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
@ -3348,7 +3348,7 @@ SQL;
), ),
'`testName` date' '`testName` date'
), ),
//set #6 // integer with length
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
@ -3358,7 +3358,7 @@ SQL;
), ),
'`testName` int(11)' '`testName` int(11)'
), ),
//set #7 // unsigned decimal
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
@ -3367,7 +3367,7 @@ SQL;
), ),
'`testName` decimal UNSIGNED' '`testName` decimal UNSIGNED'
), ),
//set #8 // decimal with default
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
@ -3377,21 +3377,21 @@ SQL;
), ),
'`testName` decimal UNSIGNED DEFAULT 1' '`testName` decimal UNSIGNED DEFAULT 1'
), ),
//set #9 // smallinteger
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
'type' => 'smallint', 'type' => 'smallinteger',
'length' => 6, 'length' => 6,
'unsigned' => true 'unsigned' => true
), ),
'`testName` smallint(6) UNSIGNED' '`testName` smallint(6) UNSIGNED'
), ),
//set #10 // tinyinteger
array( array(
array( array(
'name' => 'testName', 'name' => 'testName',
'type' => 'tinyint', 'type' => 'tinyinteger',
'length' => 4, 'length' => 4,
'unsigned' => true 'unsigned' => true
), ),

View file

@ -306,7 +306,7 @@ class PostgresTest extends CakeTestCase {
$this->assertEquals('biginteger', $this->Dbo2->column('bigint')); $this->assertEquals('biginteger', $this->Dbo2->column('bigint'));
$this->assertEquals('integer', $this->Dbo2->column('integer')); $this->assertEquals('integer', $this->Dbo2->column('integer'));
$this->assertEquals('smallint', $this->Dbo2->column('smallint')); $this->assertEquals('smallinteger', $this->Dbo2->column('smallint'));
} }
/** /**

View file

@ -265,24 +265,24 @@ class SqliteTest extends CakeTestCase {
$data = array( $data = array(
'name' => 'testName', 'name' => 'testName',
'type' => 'smallint', 'type' => 'smallinteger',
'length' => 6, 'length' => 6,
'default' => 6, 'default' => 6,
'null' => false, 'null' => false,
); );
$result = $this->Dbo->buildColumn($data); $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); $this->assertEquals($expected, $result);
$data = array( $data = array(
'name' => 'testName', 'name' => 'testName',
'type' => 'tinyint', 'type' => 'tinyinteger',
'length' => 4, 'length' => 4,
'default' => 4, 'default' => 4,
'null' => false, 'null' => false,
); );
$result = $this->Dbo->buildColumn($data); $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); $this->assertEquals($expected, $result);
$data = array( $data = array(
@ -412,13 +412,13 @@ class SqliteTest extends CakeTestCase {
'length' => null 'length' => null
), ),
'small_int' => array( 'small_int' => array(
'type' => 'integer', 'type' => 'smallinteger',
'null' => true, 'null' => true,
'default' => null, 'default' => null,
'length' => null 'length' => null
), ),
'tiny_int' => array( 'tiny_int' => array(
'type' => 'integer', 'type' => 'tinyinteger',
'null' => true, 'null' => true,
'default' => null, 'default' => null,
'length' => null 'length' => null

View file

@ -532,12 +532,12 @@ class SqlserverTest extends CakeTestCase {
$expected = '[client_id] int NULL'; $expected = '[client_id] int NULL';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$column = array('type' => 'smallint', 'name' => 'client_id'); $column = array('type' => 'smallinteger', 'name' => 'client_id');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[client_id] smallint NULL'; $expected = '[client_id] smallint NULL';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$column = array('type' => 'tinyint', 'name' => 'client_id'); $column = array('type' => 'tinyinteger', 'name' => 'client_id');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[client_id] tinyint NULL'; $expected = '[client_id] tinyint NULL';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);

View file

@ -34,8 +34,8 @@ class DatatypeFixture extends CakeTestFixture {
'decimal_field' => array('type' => 'decimal', 'length' => '6,3', 'default' => '0.000'), 'decimal_field' => array('type' => 'decimal', 'length' => '6,3', 'default' => '0.000'),
'huge_int' => array('type' => 'biginteger'), 'huge_int' => array('type' => 'biginteger'),
'normal_int' => array('type' => 'integer'), 'normal_int' => array('type' => 'integer'),
'small_int' => array('type' => 'smallint'), 'small_int' => array('type' => 'smallinteger'),
'tiny_int' => array('type' => 'tinyint'), 'tiny_int' => array('type' => 'tinyinteger'),
'bool' => array('type' => 'boolean', 'null' => false, 'default' => false), 'bool' => array('type' => 'boolean', 'null' => false, 'default' => false),
); );

View file

@ -40,10 +40,10 @@ class UnsignedFixture extends CakeTestFixture {
public $fields = array( public $fields = array(
'uinteger' => array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key' => 'primary', 'unsigned' => true), 'uinteger' => array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key' => 'primary', 'unsigned' => true),
'integer' => array('type' => 'integer', 'length' => '8', 'unsigned' => false), 'integer' => array('type' => 'integer', 'length' => '8', 'unsigned' => false),
'usmallint' => array('type' => 'smallint', 'unsigned' => true), 'usmallinteger' => array('type' => 'smallinteger', 'unsigned' => true),
'smallint' => array('type' => 'smallint', 'unsigned' => false), 'smallinteger' => array('type' => 'smallinteger', 'unsigned' => false),
'utinyint' => array('type' => 'tinyint', 'unsigned' => true), 'utinyinteger' => array('type' => 'tinyinteger', 'unsigned' => true),
'tinyint' => array('type' => 'tinyint', 'unsigned' => false), 'tinyinteger' => array('type' => 'tinyinteger', 'unsigned' => false),
'udecimal' => array('type' => 'decimal', 'length' => '4', 'unsigned' => true), 'udecimal' => array('type' => 'decimal', 'length' => '4', 'unsigned' => true),
'decimal' => array('type' => 'decimal', 'length' => '4'), 'decimal' => array('type' => 'decimal', 'length' => '4'),
'biginteger' => array('type' => 'biginteger', 'length' => '20', 'default' => 3), 'biginteger' => array('type' => 'biginteger', 'length' => '20', 'default' => 3),

View file

@ -1245,8 +1245,8 @@ class FormHelper extends AppHelper {
'date' => 'date', 'date' => 'date',
'float' => 'number', 'float' => 'number',
'integer' => 'number', 'integer' => 'number',
'smallint' => 'number', 'smallinteger' => 'number',
'tinyint' => 'number', 'tinyinteger' => 'number',
'decimal' => 'number', 'decimal' => 'number',
'binary' => 'file' 'binary' => 'file'
); );