Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-10-08 09:40:24 +02:00
commit e376794aba
2 changed files with 27 additions and 0 deletions

View File

@ -365,6 +365,13 @@ class Table
} else {
if ($attribute != '') {
$query .= ' ' . $attribute;
if ($is_timestamp
&& preg_match('/TIMESTAMP/i', $attribute)
&& $length !== 0
) {
$query .= '(' . $length . ')';
}
}
$matches = preg_match(
@ -420,6 +427,9 @@ class Table
// else fall-through intended, no break here
case 'CURRENT_TIMESTAMP' :
$query .= ' DEFAULT ' . $default_type;
if ($length !== 0 && $is_timestamp) {
$query .= '(' . $length . ')';
}
break;
case 'NONE' :
default :

View File

@ -516,7 +516,24 @@ class TableTest extends PMATestCase
$query
);
// $type is 'TIMESTAMP(3), $default_type is CURRENT_TIMESTAMP(3)
$type = 'TIMESTAMP';
$length = '3';
$extra = '';
$default_type = 'CURRENT_TIMESTAMP';
$query = Table::generateFieldSpec(
$name, $type, $length, $attribute, $collation,
$null, $default_type, $default_value, $extra, $comment,
$virtuality, $expression, $move_to
);
$this->assertEquals(
"`PMA_name` TIMESTAMP(3) PMA_attribute NULL DEFAULT CURRENT_TIMESTAMP(3) "
. "COMMENT 'PMA_comment' FIRST",
$query
);
//$default_type is NONE
$type = 'BOOLEAN';
$default_type = 'NONE';
$extra = 'INCREMENT';
$move_to = '-first';