Skip to content

Commit 98aa4ed

Browse files
author
Carlos Cima
committed
Included support for double unsigned column type.
1 parent 5ec8a7c commit 98aa4ed

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/RegExpPattern.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class RegExpPattern
1111
'binary',
1212
'real',
1313
'decimal\((?<decimalLength>\d+),(?<decimalPrecision>\d+)\)',
14-
'double(?:\((?<doubleLength>\d+),(?<doublePrecision>\d+)\))?',
14+
'double(?:\((?<doubleLength>\d+),(?<doublePrecision>\d+)\))?(?:\s+unsigned)?',
1515
'datetime',
1616
'date',
1717
'time',
@@ -69,7 +69,7 @@ public static function column()
6969
*/
7070
public static function dataType()
7171
{
72-
return '/(?<dataType>[^\(]+)\s*(?:\([^\)]+\))?\s*(?<unsigned>unsigned)?/';
72+
return '/(?<dataType>[^\(\s]+)\s*(?:\([^\)]+\))?\s*(?<unsigned>unsigned)?/';
7373
}
7474

7575
/**

tests/ParserTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,17 @@ public function testIsParsingTableWithPartitionDefinitions()
273273
$this->assertCount(1, $database->getTables());
274274
$this->assertCount(9, $database->getTableByName('export')->getColumns());
275275
}
276+
277+
public function testIsParsingDoubleUnsignedType()
278+
{
279+
$parser = new Parser();
280+
281+
$database = $parser->parseDatabase($this->getDatabaseFixture('jos_finder_links.sql'));
282+
283+
$this->assertInstanceOf(Database::class, $database);
284+
$this->assertCount(1, $database->getTables());
285+
$this->assertCount(19, $database->getTableByName('jos_finder_links')->getColumns());
286+
$this->assertEquals('double unsigned', $database->getTableByName('jos_finder_links')->getColumnByName('list_price')->getColumnType());
287+
$this->assertEquals('double', $database->getTableByName('jos_finder_links')->getColumnByName('list_price')->getDataType());
288+
}
276289
}

tests/fixtures/jos_finder_links.sql

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
CREATE TABLE `jos_finder_links` (
2+
`link_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
3+
`url` varchar(255) NOT NULL,
4+
`route` varchar(255) NOT NULL,
5+
`title` varchar(400) DEFAULT NULL,
6+
`description` varchar(255) DEFAULT NULL,
7+
`indexdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
8+
`md5sum` varchar(32) DEFAULT NULL,
9+
`published` tinyint(1) NOT NULL DEFAULT '1',
10+
`state` int(5) DEFAULT '1',
11+
`access` int(5) DEFAULT '0',
12+
`language` varchar(8) NOT NULL,
13+
`publish_start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
14+
`publish_end_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
15+
`start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
16+
`end_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
17+
`list_price` double unsigned NOT NULL DEFAULT '0',
18+
`sale_price` double unsigned NOT NULL DEFAULT '0',
19+
`type_id` int(11) NOT NULL,
20+
`object` mediumblob NOT NULL,
21+
PRIMARY KEY (`link_id`),
22+
KEY `idx_type` (`type_id`),
23+
KEY `idx_md5` (`md5sum`),
24+
KEY `idx_url` (`url`(75)),
25+
KEY `idx_published_list` (`published`,`state`,`access`,`publish_start_date`,`publish_end_date`,`list_price`),
26+
KEY `idx_published_sale` (`published`,`state`,`access`,`publish_start_date`,`publish_end_date`,`sale_price`),
27+
KEY `idx_title` (`title`(100))
28+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

0 commit comments

Comments
 (0)