Skip to content

Commit

Permalink
Fix warning for DEFAULT 0 in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
bfanger committed Jul 26, 2018
1 parent 0f71796 commit 32298ca
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Backend/DatabaseRepositoryBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,12 @@ private function getSchemaMySql($db, $prefix = '')

case 'DEFAULT':
$default = '';
while ($part = $parts[$i + 1]) {
while (true) {
++$i;
if (array_key_exists($i, $parts) === false) {
break;
}
$part = $parts[$i];
$default .= $part;
if (substr($default, 0, 1) != "'") { // Not a quoted string value?
break; // end for loop
Expand All @@ -529,11 +533,18 @@ private function getSchemaMySql($db, $prefix = '')
case 'NULL':
$default = null;
break;
case 'current_timestamp()':
case 'CURRENT_TIMESTAMP':
$default = null;
break;
default:
notice('Unknown default "'.$default.'" in "'.$line.'"');
if (preg_match('/^[0-9]+$/', $default)) {
$default = (int) $default;
} elseif (preg_match('/^[0-9]*\.[0-9+]+$/', $default)) {
$default = (float) $default;
} else {
notice('Unknown default "'.$default.'" in "'.$line.'"');
}
break;
}
$config['columns'][$column]['default'] = $default;
Expand Down

0 comments on commit 32298ca

Please sign in to comment.