Skip to content
Permalink
Browse files

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

Make the new types consistent with the biginteger.
  • Loading branch information...
markstory committed Mar 12, 2017
1 parent d78829b commit b6372d63d95dd42c5cb984a5dd568aa062134303
@@ -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'];
@@ -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 @@ 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';
@@ -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 @@ 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):
@@ -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 @@ 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';
}
@@ -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 @@ 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';
@@ -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()
@@ -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');
@@ -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');
@@ -3291,7 +3291,7 @@ public function testBuildColumnUnsigned($data, $expected) {
*/
public function buildColumnUnsignedProvider() {
return array(
//set #0
// unsigned int
array(
array(
'name' => 'testName',
@@ -3301,7 +3301,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` int(11) UNSIGNED'
),
//set #1
// unsigned bigint
array(
array(
'name' => 'testName',
@@ -3311,7 +3311,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` bigint(20) UNSIGNED'
),
//set #2
// unsigned float
array(
array(
'name' => 'testName',
@@ -3320,7 +3320,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` float UNSIGNED'
),
//set #3
// varchar
array(
array(
'name' => 'testName',
@@ -3330,7 +3330,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` varchar(255)'
),
//set #4
// date unsigned
array(
array(
'name' => 'testName',
@@ -3339,7 +3339,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` date'
),
//set #5
// date
array(
array(
'name' => 'testName',
@@ -3348,7 +3348,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` date'
),
//set #6
// integer with length
array(
array(
'name' => 'testName',
@@ -3358,7 +3358,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` int(11)'
),
//set #7
// unsigned decimal
array(
array(
'name' => 'testName',
@@ -3367,7 +3367,7 @@ public function buildColumnUnsignedProvider() {
),
'`testName` decimal UNSIGNED'
),
//set #8
// decimal with default
array(
array(
'name' => 'testName',
@@ -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
),
@@ -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'));
}
/**
@@ -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(
@@ -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
@@ -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);
@@ -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),
);
@@ -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),
@@ -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'
);

0 comments on commit b6372d6

Please sign in to comment.
You can’t perform that action at this time.