Skip to content

Commit d4995a3

Browse files
Fix wrong data-type mapping for bigint/biginteger.
Every other integer mapping, either of type FOO{int,integer} or unsignedFOO{int,integer} mapped to FOOInteger or unsignedFOOInteger, respectively. With the previous mapping to bigIncrements, Field->getMaxValue promptly blew up when you fed it a big{int,integer} with a ValueOutOfRange exception. This commit fixes big{int,integer} to follow the pattern established by the other integer types in the data-type map.
1 parent 91b7817 commit d4995a3

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/Support/Config.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ public static function dataTypeMap()
372372
'date' => 'date',
373373
'datetime' => 'dateTime',
374374
'datetimetz' => 'dateTimeTz',
375-
'biginteger' => 'bigIncrements',
376-
'bigint' => 'bigIncrements',
375+
'biginteger' => 'bigInteger',
376+
'bigint' => 'bigInteger',
377377
'tinyblob' => 'binary',
378378
'mediumblob' => 'binary',
379379
'blob' => 'binary',

tests/FieldTest.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace CrestApps\CodeGenerator\Tests;
4+
5+
use CrestApps\CodeGenerator\Models\Field;
6+
use CrestApps\CodeGenerator\Support\FieldTransformer;
7+
8+
class FieldTest extends TestCase
9+
{
10+
/** @test */
11+
public function testEloquentDataMethodForBigInt()
12+
{
13+
$sourceString = 'name:foo_count;data-type:bigint';
14+
15+
$fields = FieldTransformer::fromString($sourceString, 'generic');
16+
$this->assertTrue(is_array($fields) && 1 == count($fields));
17+
$field = $fields[0];
18+
19+
$expected = 'bigInteger';
20+
$actual = $field->getEloquentDataMethod();
21+
$this->assertEquals($expected, $actual);
22+
}
23+
24+
public function testEloquentDataMethodForBigInteger()
25+
{
26+
$sourceString = 'name:foo_count;data-type:biginteger';
27+
28+
$fields = FieldTransformer::fromString($sourceString, 'generic');
29+
$this->assertTrue(is_array($fields) && 1 == count($fields));
30+
$field = $fields[0];
31+
32+
$expected = 'bigInteger';
33+
$actual = $field->getEloquentDataMethod();
34+
$this->assertEquals($expected, $actual);
35+
}
36+
}

0 commit comments

Comments
 (0)