Pull-request: #16634 Fixes: #16575 Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
commit
af1e90be51
@ -591,6 +591,9 @@ class Table
|
||||
// a TIMESTAMP does not accept DEFAULT '0'
|
||||
// but DEFAULT 0 works
|
||||
$query .= ' DEFAULT 0';
|
||||
} elseif ($is_timestamp
|
||||
&& preg_match('/^\'\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d(\.\d{1,6})?\'$/', $default_value)) {
|
||||
$query .= ' DEFAULT ' . $default_value;
|
||||
} elseif ($type === 'BIT') {
|
||||
$query .= ' DEFAULT b\''
|
||||
. preg_replace('/[^01]/', '0', (string) $default_value)
|
||||
|
||||
@ -649,6 +649,84 @@ class TableTest extends AbstractTestCase
|
||||
$query
|
||||
);
|
||||
|
||||
$type = 'TIMESTAMP';
|
||||
$length = '';
|
||||
$extra = '';
|
||||
$default_type = 'USER_DEFINED';
|
||||
$default_value = '\'0000-00-00 00:00:00\'';
|
||||
$query = Table::generateFieldSpec(
|
||||
$name,
|
||||
$type,
|
||||
$length,
|
||||
$attribute,
|
||||
$collation,
|
||||
$null,
|
||||
$default_type,
|
||||
$default_value,
|
||||
$extra,
|
||||
$comment,
|
||||
$virtuality,
|
||||
$expression,
|
||||
$move_to
|
||||
);
|
||||
$this->assertEquals(
|
||||
'`PMA_name` TIMESTAMP PMA_attribute NULL DEFAULT \'0000-00-00 00:00:00\' '
|
||||
. "COMMENT 'PMA_comment' FIRST",
|
||||
$query
|
||||
);
|
||||
|
||||
$type = 'TIMESTAMP';
|
||||
$length = '';
|
||||
$extra = '';
|
||||
$default_type = 'USER_DEFINED';
|
||||
$default_value = '\'0000-00-00 00:00:00.0\'';
|
||||
$query = Table::generateFieldSpec(
|
||||
$name,
|
||||
$type,
|
||||
$length,
|
||||
$attribute,
|
||||
$collation,
|
||||
$null,
|
||||
$default_type,
|
||||
$default_value,
|
||||
$extra,
|
||||
$comment,
|
||||
$virtuality,
|
||||
$expression,
|
||||
$move_to
|
||||
);
|
||||
$this->assertEquals(
|
||||
'`PMA_name` TIMESTAMP PMA_attribute NULL DEFAULT \'0000-00-00 00:00:00.0\' '
|
||||
. "COMMENT 'PMA_comment' FIRST",
|
||||
$query
|
||||
);
|
||||
|
||||
$type = 'TIMESTAMP';
|
||||
$length = '';
|
||||
$extra = '';
|
||||
$default_type = 'USER_DEFINED';
|
||||
$default_value = '\'0000-00-00 00:00:00.000000\'';
|
||||
$query = Table::generateFieldSpec(
|
||||
$name,
|
||||
$type,
|
||||
$length,
|
||||
$attribute,
|
||||
$collation,
|
||||
$null,
|
||||
$default_type,
|
||||
$default_value,
|
||||
$extra,
|
||||
$comment,
|
||||
$virtuality,
|
||||
$expression,
|
||||
$move_to
|
||||
);
|
||||
$this->assertEquals(
|
||||
'`PMA_name` TIMESTAMP PMA_attribute NULL DEFAULT \'0000-00-00 00:00:00.000000\' '
|
||||
. "COMMENT 'PMA_comment' FIRST",
|
||||
$query
|
||||
);
|
||||
|
||||
//$default_type is NONE
|
||||
$type = 'BOOLEAN';
|
||||
$default_type = 'NONE';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user