Skip to content

Commit

Permalink
Merge branch 'fix-unsigned'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sartor committed Nov 28, 2018
2 parents 51ce5fa + 6d0e1d4 commit 650bea1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ protected function loadColumnSchema($info)
$column->name = $info['name'];
$column->dbType = $info['type'];

$column->unsigned = stripos($column->dbType, 'UInt') === 0;

foreach ($this->typeMap as $dbType => $type) {
if (strncasecmp($column->dbType, $dbType, strlen($dbType)) === 0) {
$column->type = $type;
Expand Down
20 changes: 20 additions & 0 deletions tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,24 @@ public function testSize()
$this->assertSame(20, $column->size);
}

public function testUnsigned()
{
$columns = $this->getConnection()->getSchema()->getTableSchema('types', true)->columns;

$this->assertTrue($columns['UInt8']->unsigned);
$this->assertTrue($columns['UInt16']->unsigned);
$this->assertTrue($columns['UInt32']->unsigned);
$this->assertTrue($columns['UInt64']->unsigned);

$this->assertFalse($columns['Int8']->unsigned);
$this->assertFalse($columns['Int16']->unsigned);
$this->assertFalse($columns['Int32']->unsigned);
$this->assertFalse($columns['Int64']->unsigned);
$this->assertFalse($columns['Float32']->unsigned);
$this->assertFalse($columns['Float64']->unsigned);
$this->assertFalse($columns['Decimal9_2']->unsigned);
$this->assertFalse($columns['Decimal18_4']->unsigned);
$this->assertFalse($columns['Decimal38_10']->unsigned);
}

}

0 comments on commit 650bea1

Please sign in to comment.